controllers: use single error handling for all CRs#1964
Merged
AndrewChubatiuk merged 1 commit intomasterfrom Mar 17, 2026
Merged
controllers: use single error handling for all CRs#1964AndrewChubatiuk merged 1 commit intomasterfrom
AndrewChubatiuk merged 1 commit 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.
00bc895 to
694ce24
Compare
2987f8d to
f10cba6
Compare
vrutkovs
reviewed
Mar 17, 2026
| resultErr = err | ||
| } | ||
| if object != nil && !reflect.ValueOf(object).IsNil() && object.GetNamespace() != "" { | ||
| if err != nil && object != nil && !reflect.ValueOf(object).IsNil() && object.GetNamespace() != "" { |
Collaborator
There was a problem hiding this comment.
Why not resultErr? Not sure if we want to emit a new event on every GET failure and parsing error
Contributor
Author
There was a problem hiding this comment.
removed resultErr, initially it was added for a different reason
f10cba6 to
551ba04
Compare
vrutkovs
approved these changes
Mar 17, 2026
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 how status metadata is read from CRs. Adds graceful shutdown handling and better error propagation while keeping NotFound silent and requeuing on cancellations and conflicts.
Refactors
handleReconcileErrWithoutStatus; all controllers now use a singlehandleReconcileErr.GetStatusMetadatafrom Status structs to parent CRs; updated helpers (waitForStatus, status updates) to read metadata from the CR.GetStatus/DefaultStatusFieldsforVMAlertmanagerConfig,VMRule,VMUser, and scrape CRs (VMNodeScrape,VMPodScrape,VMProbe,VMScrapeConfig,VMServiceScrape,VMStaticScrape); standardized controllers to use value instances and pass pointers.Bug Fixes
context.Canceledunless caused by graceful shutdown (operator.ErrShutdown); keep NotFound silent and back off on conflicts.spec.ParsingError;VMRuleandVMUsercapture JSON parse errors during unmarshal.Written for commit 551ba04. Summary will update on new commits.