Skip to content

Commit

Permalink
Save/Restore condition transition time for control plane
Browse files Browse the repository at this point in the history
This is needed as we are resetting the condition state of each reconcile
but the changing lastTransitionTime field causes reconcile loops.
  • Loading branch information
gibizer committed Apr 12, 2024
1 parent 7c14614 commit cd32840
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/core/openstackcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,14 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr
return ctrl.Result{}, err
}

// Save a copy of the conditions 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() {
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 cd32840

Please sign in to comment.