From 2b8787ad7c67f234a3d9f760af05c0946265298a Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Fri, 6 Sep 2024 14:51:45 +0300 Subject: [PATCH] Move autoupdate-spec annotation removal --- pkg/reconciliation/constructor.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/reconciliation/constructor.go b/pkg/reconciliation/constructor.go index ea8af3af..dd06171b 100644 --- a/pkg/reconciliation/constructor.go +++ b/pkg/reconciliation/constructor.go @@ -76,17 +76,6 @@ func setOperatorProgressStatus(rc *ReconciliationContext, newState api.ProgressS monitoring.UpdateOperatorDatacenterProgressStatusMetric(rc.Datacenter, newState) - // The allow-upgrade=once annotation is temporary and should be removed after first successful reconcile - if metav1.HasAnnotation(rc.Datacenter.ObjectMeta, api.UpdateAllowedAnnotation) && rc.Datacenter.Annotations[api.UpdateAllowedAnnotation] == string(api.AllowUpdateOnce) { - // remove the annotation - patch = client.MergeFrom(rc.Datacenter.DeepCopy()) - delete(rc.Datacenter.ObjectMeta.Annotations, api.UpdateAllowedAnnotation) - if err := rc.Client.Patch(rc.Ctx, rc.Datacenter, patch); err != nil { - rc.ReqLogger.Error(err, "error removing the allow-upgrade=once annotation") - return err - } - } - return nil } @@ -104,5 +93,16 @@ func setDatacenterStatus(rc *ReconciliationContext) error { return err } + // The allow-upgrade=once annotation is temporary and should be removed after first successful reconcile + if metav1.HasAnnotation(rc.Datacenter.ObjectMeta, api.UpdateAllowedAnnotation) && rc.Datacenter.Annotations[api.UpdateAllowedAnnotation] == string(api.AllowUpdateOnce) { + // remove the annotation + patch := client.MergeFrom(rc.Datacenter.DeepCopy()) + delete(rc.Datacenter.ObjectMeta.Annotations, api.UpdateAllowedAnnotation) + if err := rc.Client.Patch(rc.Ctx, rc.Datacenter, patch); err != nil { + rc.ReqLogger.Error(err, "error removing the allow-upgrade=once annotation") + return err + } + } + return nil }