Repository navigation
RHINENG-29406: compress remediations messages - #2359
katarinazaprazna merged 1 commit into
Conversation
Reviewer's GuideRemediation updates now use a dedicated Kafka writer configured for GZIP compression and 24 MiB uncompressed batches, while updates that still exceed Kafka’s size limit are logged and skipped instead of failing publication. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2359 +/- ##
==========================================
- Coverage 58.95% 58.89% -0.07%
==========================================
Files 151 151
Lines 9690 9706 +16
==========================================
+ Hits 5713 5716 +3
- Misses 3375 3386 +11
- Partials 602 604 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a140b32 to
3cf9b48
Compare
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="evaluator/remediations.go" line_range="106" />
<code_context>
+ if isRemediationsMessageTooLarge(err) {
+ utils.LogError("inventoryID", state.HostID, "issue_count", len(state.Issues),
+ "uncompressed_bytes", len(msg.Value), "err", err, "Remediations update skipped: message too large")
+ return nil
+ }
return base.WrapFatalKafkaError(err, "write message")
</code_context>
<issue_to_address>
**Remediation snapshots remain stale**
When kafka rejects a remediation snapshot as too large, `publishRemediationsState` returns nil after logging the rejected write, so `Evaluate` and `evaluateHandler` treat the evaluation as successful and commit the input event. Consumers receive no replacement snapshot and retain missing or stale remediation state.
Return a non-nil error, or otherwise prevent the input event from being committed, when the snapshot write is rejected.
</issue_to_address>
### Comment 2
<location path="evaluator/remediations.go" line_range="120" />
<code_context>
+ }
+ err = writeErrors[0]
+ }
+ return errors.Is(err, kafka.MessageSizeTooLarge)
+}
</code_context>
<issue_to_address>
**Broker-rejected updates remain fatal**
When the broker rejects a compressed record batch for exceeding its configured size limit, `isRemediationsMessageTooLarge` matches only `kafka.MessageSizeTooLarge`; kafka-go reports a broker `MESSAGE_TOO_LARGE` response as `kafka.MessageTooLarge`, so `publishRemediationsState` wraps that rejection as fatal instead of logging and skipping it.
Recognize kafka-go’s broker-side `kafka.MessageTooLarge` error as well as the local `kafka.MessageSizeTooLarge` sentinel.
</issue_to_address>
### Comment 3
<location path="evaluator/remediations.go" line_range="111-120" />
<code_context>
return base.WrapFatalKafkaError(err, "write message")
}
+
+func isRemediationsMessageTooLarge(err error) bool {
+ // Broker errors are wrapped in WriteErrors, which errors.Is does not unwrap
+ var writeErrors kafka.WriteErrors
+ if errors.As(err, &writeErrors) {
+ if len(writeErrors) != 1 {
+ return false
+ }
+ err = writeErrors[0]
+ }
+ return errors.Is(err, kafka.MessageSizeTooLarge)
+}
</code_context>
<issue_to_address>
**Size handling depends on Kafka error types**
When the remediation writer reports a too-large rejection without exposing a kafka-go `MessageSizeTooLarge` error, `isRemediationsMessageTooLarge` recognizes only kafka-go error wrappers, although `mqueue.Writer` exposes a generic `error` contract. A writer that reports an oversized message in another error shape bypasses the skip path and causes `publishRemediationsState` to return a fatal Kafka error.
Have the mqueue layer classify oversized-message failures behind a backend-independent error contract, and handle that contract in the evaluator.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and an oversized remediation update is logged and treated as successful without being published, which can leave downstream remediation state stale. Reverting restores the previous writer behavior but cannot recover updates already skipped.
Blocking findings: evaluator/remediations.go:106, evaluator/remediations.go:120
Summary
Secure Coding Practices Checklist GitHub Link
Secure Coding Checklist
Summary by Sourcery
Compress remediation updates and gracefully handle messages that exceed Kafka size limits.
New Features:
Bug Fixes: