Skip to content

RHINENG-26118: add patchman.advisory.update Kafka topic#2194

Open
katarinazaprazna wants to merge 3 commits into
RedHatInsights:masterfrom
katarinazaprazna:add-advisory-update-topic
Open

RHINENG-26118: add patchman.advisory.update Kafka topic#2194
katarinazaprazna wants to merge 3 commits into
RedHatInsights:masterfrom
katarinazaprazna:add-advisory-update-topic

Conversation

@katarinazaprazna
Copy link
Copy Markdown

@katarinazaprazna katarinazaprazna commented May 13, 2026

  • Add patchman.advisory.update Kafka topic config
  • Remove kafkaTopics section from ClowdApp - topics are provisioned externally by the Platform team
  • Add AdvisoryUpdateEvent message contract and WriteEvents function

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Add configuration and infrastructure support for a new advisory update Kafka topic.

New Features:

  • Introduce configuration entry for an advisory update Kafka topic in the core configuration.

Build:

  • Provision the patchman.advisory.update Kafka topic in ClowdApp deployment configuration and local Kafka setup scripts.

Summary by Sourcery

Add support for publishing advisory update events to Kafka and align topic configuration with external provisioning.

New Features:

  • Introduce configuration for an advisory update Kafka topic and expose it via core configuration.
  • Define an AdvisoryUpdateEvent message contract and batch writer for sending advisory update events to Kafka.

Enhancements:

  • Adjust local Kafka setup to include the advisory update topic used for development and testing.

Deployment:

  • Remove Kafka topic provisioning from the ClowdApp manifest to rely on externally managed topics.

Tests:

  • Add unit tests covering advisory update event serialization and Kafka message writing behavior.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 13, 2026

Reviewer's Guide

Adds configuration and contract support for a new patchman.advisory.update Kafka topic, wires it into local dev tooling, and introduces typed advisory update event publishing with unit tests, while delegating topic provisioning away from the ClowdApp manifest.

File-Level Changes

Change Details Files
Wire a new advisory update Kafka topic into configuration and dev tooling while removing in-app topic provisioning.
  • Extend core Kafka topic configuration with an AdvisoryUpdateTopic field populated from ADVISORY_UPDATE_TOPIC environment variable.
  • Add patchman.advisory.update to the local development Kafka setup script so the topic is created for dev/test environments.
  • Remove the kafkaTopics stanza from the ClowdApp definition to rely on externally managed Kafka topics.
base/utils/config.go
dev/kafka/setup.sh
deploy/clowdapp.yaml
Introduce a strongly-typed advisory update Kafka event payload and batching write helper with tests.
  • Define AdvisoryUpdateEvent struct (including optional workspace, advisory IDs list, and RFC3339 timestamp) and AdvisoryUpdateEvents slice type in the message queue package.
  • Implement JSON serialization for single advisory update events and a WriteEvents method that converts a slice of events into Kafka messages and writes them through the existing Writer interface.
  • Add unit tests to validate JSON marshal/unmarshal behavior (with and without workspace) and that WriteEvents produces the expected Kafka messages when used with a mock writer.
base/mqueue/advisory_update_event.go
base/mqueue/advisory_update_event_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 13, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.06%. Comparing base (ee9c711) to head (c62a807).

Files with missing lines Patch % Lines
base/mqueue/advisory_update_event.go 69.23% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2194      +/-   ##
==========================================
- Coverage   59.06%   59.06%   -0.01%     
==========================================
  Files         136      137       +1     
  Lines        8761     8775      +14     
==========================================
+ Hits         5175     5183       +8     
- Misses       3040     3044       +4     
- Partials      546      548       +2     
Flag Coverage Δ
unittests 59.06% <71.42%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@katarinazaprazna katarinazaprazna force-pushed the add-advisory-update-topic branch from f36b936 to e0d1034 Compare May 14, 2026 21:37
@katarinazaprazna katarinazaprazna marked this pull request as ready for review May 14, 2026 21:38
@katarinazaprazna katarinazaprazna requested a review from a team as a code owner May 14, 2026 21:38
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="base/mqueue/advisory_update_event_test.go" line_range="34" />
<code_context>
+	assert.Equal(t, *event.WorkspaceID, *parsed.WorkspaceID)
+	assert.Equal(t, event.InventoryID, parsed.InventoryID)
+	assert.Equal(t, event.AdvisoryIDs, parsed.AdvisoryIDs)
+	assert.NotNil(t, parsed.ProducedAt)
+}
+
</code_context>
<issue_to_address>
**suggestion (testing):** Strengthen the assertion to verify the `ProducedAt` value is preserved, not just non-nil.

Since `ProducedAt` is set before marshaling, assert equality with the original value (e.g. `assert.Equal(t, *event.ProducedAt, *parsed.ProducedAt)`) rather than just non-nil, so the timestamp round-trip is fully verified. The same pattern can be applied to the other tests that currently use `assert.NotNil` on `ProducedAt`.

Suggested implementation:

```golang
	assert.Equal(t, *event.WorkspaceID, *parsed.WorkspaceID)
	assert.Equal(t, event.InventoryID, parsed.InventoryID)
	assert.Equal(t, event.AdvisoryIDs, parsed.AdvisoryIDs)
	assert.NotNil(t, parsed.ProducedAt)
	assert.Equal(t, *event.ProducedAt, *parsed.ProducedAt)

```

To fully apply your comment across the test suite, also:
1. Search in `base/mqueue/advisory_update_event_test.go` for other occurrences of `assert.NotNil(t, parsed.ProducedAt)` (or similar patterns with a different variable name, e.g. `assert.NotNil(t, parsedEvent.ProducedAt)`).
2. For each occurrence, add an equality assertion of the form `assert.Equal(t, *<originalEventVar>.ProducedAt, *<parsedVar>.ProducedAt)` next to or instead of the `NotNil` check, using the appropriate variable names for that test.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread base/mqueue/advisory_update_event_test.go
Comment thread base/mqueue/advisory_update_event.go Outdated
Comment thread base/mqueue/advisory_update_event.go Outdated
@MichaelMraka MichaelMraka self-assigned this May 15, 2026
Kafka topics are provisioned externally by the Platform team, Clowder
does not need to create them. Our components reference topics via
environment variables in their deployment specs, which are independent
of this section.
@katarinazaprazna katarinazaprazna force-pushed the add-advisory-update-topic branch from e0d1034 to 1c16d3d Compare May 15, 2026 12:30
@katarinazaprazna katarinazaprazna force-pushed the add-advisory-update-topic branch from 45b4ade to 1c16d3d Compare May 15, 2026 15:26
Comment thread base/mqueue/advisory_update_event.go Outdated
@katarinazaprazna katarinazaprazna force-pushed the add-advisory-update-topic branch from 8bf6cdc to 422341b Compare May 15, 2026 17:32
@katarinazaprazna katarinazaprazna requested a review from TenSt May 15, 2026 17:32
@katarinazaprazna katarinazaprazna force-pushed the add-advisory-update-topic branch from 422341b to c62a807 Compare May 15, 2026 17:51
Copy link
Copy Markdown
Collaborator

@TenSt TenSt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@TenSt TenSt dismissed MichaelMraka’s stale review May 15, 2026 20:28

All the requested changes were implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants