Skip to content

Commit 670e517

Browse files
committed
Version: Create helper before manipulating instance
The helper.NewHelper creates snapshot of the instance being reconciled and PatchInstance at the end of the reconcile loop uses this to generate the Patch to persist the changes done by the reconciler. Therefore the helper needs to be created before any changes on the instance. This is fixed now to avoid loosing in memory changes.
1 parent 47fcf16 commit 670e517

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎controllers/core/openstackversion_controller.go‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req
105105
return ctrl.Result{}, err
106106
}
107107

108-
isNewInstance := instance.Status.Conditions == nil
109-
if isNewInstance {
110-
instance.Status.Conditions = condition.Conditions{}
111-
}
112-
113-
// Save a copy of the condtions so that we can restore the LastTransitionTime
114-
// when a condition's state doesn't change.
115-
savedConditions := instance.Status.Conditions.DeepCopy()
116-
117108
versionHelper, err := helper.NewHelper(
118109
instance,
119110
r.Client,
@@ -126,6 +117,15 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req
126117
return ctrl.Result{}, err
127118
}
128119

120+
isNewInstance := instance.Status.Conditions == nil
121+
if isNewInstance {
122+
instance.Status.Conditions = condition.Conditions{}
123+
}
124+
125+
// Save a copy of the condtions so that we can restore the LastTransitionTime
126+
// when a condition's state doesn't change.
127+
savedConditions := instance.Status.Conditions.DeepCopy()
128+
129129
// Always patch the instance status when exiting this function so we can persist any changes.
130130
defer func() {
131131
// update the Ready condition based on the sub conditions

0 commit comments

Comments
 (0)