diff --git a/controllers/core/openstackversion_controller.go b/controllers/core/openstackversion_controller.go index ee859d2c9..c47fb030e 100644 --- a/controllers/core/openstackversion_controller.go +++ b/controllers/core/openstackversion_controller.go @@ -105,15 +105,6 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req return ctrl.Result{}, err } - isNewInstance := instance.Status.Conditions == nil - if isNewInstance { - instance.Status.Conditions = condition.Conditions{} - } - - // Save a copy of the condtions so that we can restore the LastTransitionTime - // when a condition's state doesn't change. - savedConditions := instance.Status.Conditions.DeepCopy() - versionHelper, err := helper.NewHelper( instance, r.Client, @@ -126,6 +117,15 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req return ctrl.Result{}, err } + isNewInstance := instance.Status.Conditions == nil + if isNewInstance { + instance.Status.Conditions = condition.Conditions{} + } + + // Save a copy of the condtions so that we can restore the LastTransitionTime + // when a condition's state doesn't change. + savedConditions := instance.Status.Conditions.DeepCopy() + // Always patch the instance status when exiting this function so we can persist any changes. defer func() { // update the Ready condition based on the sub conditions