diff --git a/pkg/cvo/cvo_scenarios_test.go b/pkg/cvo/cvo_scenarios_test.go index e672a466b0..a4aaebaf17 100644 --- a/pkg/cvo/cvo_scenarios_test.go +++ b/pkg/cvo/cvo_scenarios_test.go @@ -1886,7 +1886,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") @@ -2016,7 +2016,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 7f55901b16..485c41cf1a 100644 --- a/pkg/cvo/sync_worker.go +++ b/pkg/cvo/sync_worker.go @@ -406,11 +406,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 { @@ -425,6 +422,13 @@ func (w *SyncWorker) Update(ctx context.Context, generation int64, desired confi 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 + // notify the sync loop that we changed config if w.cancelFn != nil { klog.V(2).Info("Cancel the sync worker's current loop")