-
Notifications
You must be signed in to change notification settings - Fork 567
OCPBUGS-65687: fix(controlplane-component): prevent informer creation for unused platform resources #7417
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
OCPBUGS-65687: fix(controlplane-component): prevent informer creation for unused platform resources #7417
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,9 @@ type controlPlaneWorkload[T client.Object] struct { | |
|
|
||
| customOperandsRolloutCheck func(cpContext WorkloadContext) (bool, error) | ||
| monitorOperandsRolloutStatus bool | ||
|
|
||
| // tracks whether the component has been applied successfully. | ||
| hasBeenApplied bool | ||
| } | ||
|
|
||
| // Name implements ControlPlaneComponent. | ||
|
|
@@ -173,6 +176,7 @@ func (c *controlPlaneWorkload[T]) Reconcile(cpContext ControlPlaneContext) error | |
| if len(unavailableDependencies) == 0 { | ||
| // reconcile only when all dependencies are available, and don't return error immediately so it can be included in the status condition first. | ||
| reconcilationError = c.update(cpContext) | ||
| c.hasBeenApplied = true | ||
| } | ||
|
|
||
| component := &hyperv1.ControlPlaneComponent{ | ||
|
|
@@ -191,6 +195,11 @@ func (c *controlPlaneWorkload[T]) Reconcile(cpContext ControlPlaneContext) error | |
| } | ||
|
|
||
| func (c *controlPlaneWorkload[T]) delete(cpContext ControlPlaneContext) error { | ||
| if !c.hasBeenApplied { | ||
| // if the component has not been applied, it doesn't exist, so there's nothing to delete. | ||
| return nil | ||
| } | ||
|
Comment on lines
197
to
+201
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard can skip cleanup after operator restart.
🤖 Prompt for AI Agents |
||
|
|
||
| workloadObj := c.workloadProvider.NewObject() | ||
| // make sure that the Deployment/Statefulset name matches the component name. | ||
| workloadObj.SetName(c.Name()) | ||
|
|
@@ -221,8 +230,12 @@ func (c *controlPlaneWorkload[T]) delete(cpContext ControlPlaneContext) error { | |
| Namespace: cpContext.HCP.Namespace, | ||
| }, | ||
| } | ||
| _, err = util.DeleteIfNeeded(cpContext, cpContext.Client, component) | ||
| return err | ||
| if _, err := util.DeleteIfNeeded(cpContext, cpContext.Client, component); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| c.hasBeenApplied = false | ||
| return nil | ||
| } | ||
|
|
||
| // update reconciles component workload and related manifests | ||
|
|
||
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.
Set
hasBeenAppliedonly after a successful update.c.hasBeenApplied = trueruns even whenc.update(...)returns an error. That can mark components as applied even when nothing was created, undermining the “skip delete if never applied” guard. Gate this onreconcilationError == nil.✅ Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents