Skip to content

Commit

Permalink
OpenstackVersion: add save conditions logic
Browse files Browse the repository at this point in the history
without this there is a reconcile loop between
this resource and the controlplane
  • Loading branch information
dprince committed Apr 11, 2024
1 parent 0414bc0 commit 91adfe7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/core/openstackversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req
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,
Expand All @@ -124,6 +128,8 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req

// Always patch the instance status when exiting this function so we can persist any changes.
defer func() {
condition.RestoreLastTransitionTimes(
&instance.Status.Conditions, savedConditions)
// update the Ready condition based on the sub conditions
if instance.Status.Conditions.AllSubConditionIsTrue() {
instance.Status.Conditions.MarkTrue(
Expand Down

0 comments on commit 91adfe7

Please sign in to comment.