Skip to content

Commit 592dcd2

Browse files
fix: Use latest rolling-out revision instead of oldest
RollingOut revisions are sorted oldest→newest, so checking the first element (index 0) could cause unnecessary re-resolution when a newer rolling-out revision already matches the current spec. Now checks the last element (latest rolling-out revision) before deciding whether to resolve a new bundle from catalog. This prevents creating extra revisions when multiple rolling-out revisions exist (e.g., older revision stuck, newer one rolling out). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d881e80 commit 592dcd2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

internal/operator-controller/controllers/clusterextension_reconcile_steps.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,25 +140,29 @@ func ResolveBundle(r resolve.Resolver, c client.Client) ReconcileStepFunc {
140140
return func(ctx context.Context, state *reconcileState, ext *ocv1.ClusterExtension) (*ctrl.Result, error) {
141141
l := log.FromContext(ctx)
142142

143-
// If already rolling out, check if the rolling-out revision matches the current spec.
143+
// If already rolling out, check if the latest rolling-out revision matches the current spec.
144144
// If spec has changed (e.g., version updated), we need to resolve a new bundle instead of
145145
// reusing the rolling-out revision.
146+
//
147+
// Note: RollingOut slice is sorted oldest→newest, so use the last element (most recent).
148+
// This avoids re-resolving when a newer revision already matches the spec, even if an
149+
// older revision is still stuck rolling out.
146150
if len(state.revisionStates.RollingOut) > 0 {
147-
rollingOutRevision := state.revisionStates.RollingOut[0]
151+
latestRollingOutRevision := state.revisionStates.RollingOut[len(state.revisionStates.RollingOut)-1]
148152
specVersion := ""
149153
if ext.Spec.Source.Catalog != nil {
150154
specVersion = ext.Spec.Source.Catalog.Version
151155
}
152156

153-
// If spec version matches rolling-out revision version (or no version specified),
157+
// If spec version matches latest rolling-out revision version (or no version specified),
154158
// reuse the existing rolling-out revision
155-
if specVersion == "" || specVersion == rollingOutRevision.Version {
159+
if specVersion == "" || specVersion == latestRollingOutRevision.Version {
156160
installedBundleName := ""
157161
if state.revisionStates.Installed != nil {
158162
installedBundleName = state.revisionStates.Installed.Name
159163
}
160164
SetDeprecationStatus(ext, installedBundleName, nil, false)
161-
state.resolvedRevisionMetadata = rollingOutRevision
165+
state.resolvedRevisionMetadata = latestRollingOutRevision
162166
return nil, nil
163167
}
164168
// Spec version changed - fall through to resolve new bundle from catalog

0 commit comments

Comments
 (0)