fix(central): improve compliance scan watcher diagnostic logging#20903
Draft
guzalv wants to merge 2 commits into
Draft
fix(central): improve compliance scan watcher diagnostic logging#20903guzalv wants to merge 2 commits into
guzalv wants to merge 2 commits into
Conversation
Timeout and cancellation log messages now include received vs expected counts and watcher IDs. DeleteOldResultsFromMissingScans now logs which scans are being cleaned up and their cluster/scanRefId. These diagnostics are needed to triage scan watcher timeouts in customer environments. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Skipping CI for Draft Pull Request. |
Contributor
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@central/complianceoperator/v2/report/manager/watcher/scanwatcher.go`:
- Around line 274-275: The log call in Stop may dereference s.scanResults.Scan
which is nil until handleScan sets it; update Stop (or the logging site) to
guard access by checking if s.scanResults.Scan != nil before calling
GetScanName(), and use a safe fallback (e.g. "<unknown>" or empty string) when
nil; locate NewScanWatcher, Stop, handleScan and the scanResults struct/field to
implement the guard and ensure no other code paths call GetScanName() without a
nil check.
- Around line 285-286: The timeout warning in scan watcher can nil-dereference
because s.scanResults.Scan may still be nil if the timeout fires before
handleScan initializes it. Update the timeout path in scanwatcher.go to guard
access to s.scanResults.Scan before calling GetScanName(), and fall back to a
safe message when the scan is not yet set. Use the existing scanResults/Scan
fields in the timeout logging block to keep the fix localized and consistent
with the stop-path nil-safety handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 284e3443-6aa6-4fd9-8aa9-b39932ebc45f
📒 Files selected for processing (3)
central/complianceoperator/v2/report/manager/manager_impl.gocentral/complianceoperator/v2/report/manager/watcher/scanconfigwatcher.gocentral/complianceoperator/v2/report/manager/watcher/scanwatcher.go
Add scanName() helper that falls back to watcher ID when Scan is nil. This can happen when a watcher is created by a check result event but never receives a scan event before timing out. Addresses CodeRabbit review feedback on PR #20903. Partially generated by AI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
🚀 Build Images ReadyImages are ready for commit 4bd0677. To use with deploy scripts: export MAIN_IMAGE_TAG=4.12.x-65-g4bd0677249 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Improves diagnostic logging across the compliance scan watcher system to enable faster triage of scan timeouts in customer environments.
Changes:
handleReadyScanConfiglog promoted from Debug to Info and now includes the error stateDeleteOldResultsFromMissingScansnow logs which scans are being cleaned up (scan name, scanRefId, cluster ID) and short-circuits when no scans are missingscanName()nil-safe accessor that falls back to watcher ID when Scan is nil (can happen when a watcher is created by check result events but never receives a scan event)Why: The existing timeout log (
"Timeout waiting for the scan X to finish") gives no indication of how close the scan was to completing. Knowing received/expected count (e.g., 0/150 vs 148/150) immediately narrows the root cause: missing annotation, lost results, or check-count mismatch.Before/After comparison (verified on cluster
ga-acp)Scan watcher timeout:
Scan config watcher timeout:
handleReadyScanConfig completion:
DeleteOldResultsFromMissingScans:
User-facing documentation
Testing and quality
Automated testing
How I validated my change
ga-acp: deployed master baseline, captured BEFORE logs during scan watcher timeout (2 min) and scan config watcher timeout (3 min), then deployed PR branch and captured AFTER logs under the same conditions. All 4 improvements confirmed visible — see Before/After comparison above.