controllers: use single error handling for all CRs#1964
Open
AndrewChubatiuk wants to merge 2 commits intomasterfrom
Open
controllers: use single error handling for all CRs#1964AndrewChubatiuk wants to merge 2 commits intomasterfrom
AndrewChubatiuk wants to merge 2 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
4 issues found across 49 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="api/operator/v1beta1/vmrule_types.go">
<violation number="1" location="api/operator/v1beta1/vmrule_types.go:249">
P1: Returning nil here hides VMRule JSON decode failures from admission; malformed rules can now be accepted and only fail later in reconciliation.</violation>
</file>
<file name="internal/controller/operator/vmrule_controller.go">
<violation number="1" location="internal/controller/operator/vmrule_controller.go:122">
P1: Don't only log configmap update failures here. A later successful iteration clears the shared named `err`, so this reconcile can return success after partially failing to update `VMAlert` configmaps.</violation>
</file>
<file name="internal/controller/operator/vmuser_controller.go">
<violation number="1" location="internal/controller/operator/vmuser_controller.go:131">
P1: Propagate this `CreateOrUpdateConfig` failure instead of only logging it; otherwise the reconcile returns success and controller-runtime will not retry the VMUser update.</violation>
</file>
<file name="internal/controller/operator/vmalertmanagerconfig_controller.go">
<violation number="1" location="internal/controller/operator/vmalertmanagerconfig_controller.go:75">
P2: Treat `ParsingError` as non-retryable here; returning it through `handleReconcileErr` will put malformed configs into a permanent requeue/event loop.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
a1f67e9 to
66678ab
Compare
Contributor
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/controller/operator/controllers.go">
<violation number="1" location="internal/controller/operator/controllers.go:133">
P2: Check `context.Cause(ctx)` here instead of `err`; `WithCancelCause` stores `ErrShutdown` on the context, so graceful shutdowns will usually still be requeued.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
163df38 to
00bc895
Compare
00bc895 to
694ce24
Compare
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.
Summary by cubic
Unifies error handling across all controllers and standardizes status access on CRs. Adds graceful shutdown awareness via
context.WithCancelCauseandoperator.ErrShutdown, and requeues on non-shutdown cancellations to avoid missed reconciles.Refactors
handleReconcileErr; removedhandleReconcileErrWithoutStatus.GetStatusMetadatafrom Status structs to parent CRs; updated helpers (waitForStatus, status updates) and interfaces to read metadata from the CR.GetStatus/DefaultStatusFieldsforVMAlertmanagerConfig,VMRule,VMUser, and scrape CRs (VMNodeScrape,VMPodScrape,VMProbe,VMScrapeConfig,VMServiceScrape,VMStaticScrape).VMRuleandVMUsernow capture JSON parse errors during unmarshal intoSpec.ParsingError.Bug Fixes
context.Canceledunless caused by graceful shutdown (operator.ErrShutdownviacontext.WithCancelCause); keep NotFound silent and backoff on conflicts.spec.ParsingError.Written for commit 694ce24. Summary will update on new commits.