-
Notifications
You must be signed in to change notification settings - Fork 195
reconcile: refactor freeing recreated resource finalizer removal #1772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 16 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="docs/CHANGELOG.md">
<violation number="1" location="docs/CHANGELOG.md:29">
P1: Rule violated: **Changelog Review Agent**
Changelog entries must include reference links and a user‑centric before/after explanation. This entry is missing any issue/PR link and focuses on internal implementation details (function ordering/finalizer handling) instead of a user-visible impact description, violating the changelog structure requirements (References + User-centric explanation clauses).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
389665c to
9f07ff5
Compare
|
@cubic-dev-ai review this PR |
@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 issues found across 24 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/controller/operator/factory/reconcile/vmservicescrape.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/vmservicescrape.go:43">
P3: Spec diff is computed after overwriting existingObj.Spec, so the log always shows an empty diff and loses diagnostic value. Compute the diff before assigning to existingObj.Spec.</violation>
</file>
<file name="internal/controller/operator/factory/reconcile/configmap.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/configmap.go:24">
P1: Handle non-NotFound errors from the initial Get. Otherwise, API errors are swallowed and the reconciler proceeds with an empty object, which can lead to incorrect updates or misleading retries.</violation>
</file>
<file name="internal/controller/operator/factory/reconcile/httproute.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/httproute.go:40">
P2: Use DeepDerivative here to ignore controller-defaulted fields; DeepEqual will continually detect diffs once defaults are applied to the live object.</violation>
</file>
<file name="docs/CHANGELOG.md">
<violation number="1" location="docs/CHANGELOG.md:29">
P2: Rule violated: **Changelog Review Agent**
Changelog entry doesn’t follow the required user‑centric structure: it cites an internal implementation detail (“previous resource finalizer”) and doesn’t explicitly describe the before/after user-visible behavior. The changelog rule requires a before/after explanation without internal details.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
9f07ff5 to
fae5765
Compare
|
@cubic-dev-ai review this PR |
@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 24 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/controller/operator/factory/reconcile/httproute.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/httproute.go:43">
P2: The strict DeepEqual on labels defeats the existing metadata-merge logic that preserves external labels, so any label added by another controller will force updates every reconcile. Rely on isObjectMetaEqual (which already handles label/annotation differences) to avoid update churn.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
fae5765 to
077cd83
Compare
|
@cubic-dev-ai review this PR |
@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 issues found across 38 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/controller/operator/factory/reconcile/hpa.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/hpa.go:36">
P3: `spec_diff` is always empty because the diff is computed after `existingObj.Spec` is overwritten with `newObj.Spec`. Capture the diff before mutating `existingObj.Spec` so the log reflects the actual changes.</violation>
</file>
<file name="internal/controller/operator/factory/vmalert/rules.go">
<violation number="1" location="internal/controller/operator/factory/vmalert/rules.go:53">
P2: Reconcile now overwrites existing ConfigMap annotations with nil, so third‑party annotations on rule ConfigMaps are lost on update. The previous logic merged current annotations; this change causes annotation loss.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
077cd83 to
67c0728
Compare
|
@cubic-dev-ai review this PR |
@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 49 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/controller/operator/factory/reconcile/configmap.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/configmap.go:32">
P2: BinaryData changes are ignored. The reconcile compares/updates only Data/Labels/Annotations, so any BinaryData updates will never be applied. Include BinaryData in the equality check and copy it onto the existing object before update.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| logger.WithContext(ctx).Info(fmt.Sprintf("updating ConfigMap %s configuration", newCM.Name)) | ||
|
|
||
| return rclient.Update(ctx, newCM) | ||
| if equality.Semantic.DeepEqual(newObj.Data, existingObj.Data) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: BinaryData changes are ignored. The reconcile compares/updates only Data/Labels/Annotations, so any BinaryData updates will never be applied. Include BinaryData in the equality check and copy it onto the existing object before update.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/factory/reconcile/configmap.go, line 32:
<comment>BinaryData changes are ignored. The reconcile compares/updates only Data/Labels/Annotations, so any BinaryData updates will never be applied. Include BinaryData in the equality check and copy it onto the existing object before update.</comment>
<file context>
@@ -7,41 +7,39 @@ import (
- logger.WithContext(ctx).Info(fmt.Sprintf("updating ConfigMap %s configuration", newCM.Name))
-
- return rclient.Update(ctx, newCM)
+ if equality.Semantic.DeepEqual(newObj.Data, existingObj.Data) &&
+ equality.Semantic.DeepEqual(newObj.Labels, existingObj.Labels) &&
+ equality.Semantic.DeepEqual(newObj.Annotations, existingObj.Annotations) {
</file context>
67c0728 to
f7a6626
Compare
f7a6626 to
da40408
Compare
|
@cubic-dev-ai review this PR |
@AndrewChubatiuk I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 49 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/controller/operator/factory/reconcile/httproute.go">
<violation number="1" location="internal/controller/operator/factory/reconcile/httproute.go:38">
P2: Overwriting labels/annotations drops third‑party metadata. Use the existing merge logic to preserve unmanaged labels/annotations instead of replacing the maps outright.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| return rclient.Update(ctx, newHTTPRoute) | ||
| specDiff := diffDeepDerivative(newObj.Spec, existingObj.Spec) | ||
| existingObj.Labels = newObj.Labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: Overwriting labels/annotations drops third‑party metadata. Use the existing merge logic to preserve unmanaged labels/annotations instead of replacing the maps outright.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/factory/reconcile/httproute.go, line 38:
<comment>Overwriting labels/annotations drops third‑party metadata. Use the existing merge logic to preserve unmanaged labels/annotations instead of replacing the maps outright.</comment>
<file context>
@@ -10,50 +10,35 @@ import (
-
- return rclient.Update(ctx, newHTTPRoute)
+ specDiff := diffDeepDerivative(newObj.Spec, existingObj.Spec)
+ existingObj.Labels = newObj.Labels
+ existingObj.Annotations = newObj.Annotations
+ existingObj.Spec = newObj.Spec
</file context>
related to #1707
Summary by cubic
Fixes finalizer cleanup by centralizing freeIfNeeded across reconcilers to remove stale finalizers and recreate deleted resources. Prevents resources from getting stuck and adds Ingress reconciliation plus simpler rule config updates.
Written for commit da40408. Summary will update on new commits.