diff --git a/pkg/cvo/cvo_scenarios_test.go b/pkg/cvo/cvo_scenarios_test.go index ec90571389..8e768b1cc9 100644 --- a/pkg/cvo/cvo_scenarios_test.go +++ b/pkg/cvo/cvo_scenarios_test.go @@ -2022,7 +2022,7 @@ func TestCVO_UpgradePreconditionFailing(t *testing.T) { t.Fatal(err) } actions = client.Actions() - if len(actions) != 1 { + if len(actions) != 2 { t.Fatalf("%s", spew.Sdump(actions)) } expectGet(t, actions[0], "clusterversions", "", "version") @@ -2170,7 +2170,7 @@ func TestCVO_UpgradePreconditionFailing(t *testing.T) { expectUpdateStatus(t, actions[1], "clusterversions", "", &configv1.ClusterVersion{ ObjectMeta: metav1.ObjectMeta{ Name: "version", - ResourceVersion: "3", + ResourceVersion: "4", Generation: 1, }, Spec: configv1.ClusterVersionSpec{ diff --git a/pkg/cvo/sync_worker.go b/pkg/cvo/sync_worker.go index 1d44d9484b..a7f848100f 100644 --- a/pkg/cvo/sync_worker.go +++ b/pkg/cvo/sync_worker.go @@ -439,11 +439,8 @@ func (w *SyncWorker) Update(ctx context.Context, generation int64, desired confi oldDesired = &w.work.Desired } - w.work = work - - if !versionEqual && oldDesired == nil { - klog.Infof("Propagating initial target version %v to sync worker loop in state %s.", desired, state) - } else if !versionEqual && state == payload.InitializingPayload { + // since oldDesired is not nil this is not the first time update is invoked and therefore w.work is not nil + if !versionEqual && oldDesired != nil && state == payload.InitializingPayload { klog.Warningf("Ignoring detected version change from %v to %v during payload initialization", *oldDesired, work.Desired) w.work.Desired = *oldDesired if overridesEqual && capabilitiesEqual { @@ -455,9 +452,20 @@ func (w *SyncWorker) Update(ctx context.Context, generation int64, desired confi implicit, err := w.loadUpdatedPayload(ctx, work, cvoOptrName) w.lock.Lock() if err != nil { + // save latest capability settings if not first time through + if w.work != nil { + w.work.Capabilities = work.Capabilities + } return w.status.DeepCopy() } + if !versionEqual && oldDesired == nil { + klog.Infof("Propagating initial target version %v to sync worker loop in state %s.", desired, state) + } + + // update work to include desired version now that it has been successfully loaded + w.work = work + // Update capabilities settings and status to include any capabilities that were implicitly enabled due // to previously managed resources. w.work.Capabilities = capability.SetFromImplicitlyEnabledCapabilities(implicit, w.work.Capabilities)