@@ -42,7 +42,7 @@ import (
4242// machine being partially deleted but also for running machines being disrupted e.g. by deleting the node.
4343// Additionally, this func should ensure that the conditions managed by this controller are always set in order to
4444// comply with the recommendation in the Kubernetes API guidelines.
45- func (r * Reconciler ) updateStatus (ctx context.Context , s * scope ) {
45+ func (r * Reconciler ) updateStatus (ctx context.Context , s * scope ) ctrl. Result {
4646 // Update status from the Bootstrap Config external resource.
4747 // Note: some of the status fields derived from the Bootstrap Config are managed in reconcileBootstrap, e.g. status.BootstrapReady, etc.
4848 // here we are taking care only of the delta (condition).
@@ -67,9 +67,9 @@ func (r *Reconciler) updateStatus(ctx context.Context, s *scope) {
6767 setDeletingCondition (ctx , s .machine , s .reconcileDeleteExecuted , s .deletingReason , s .deletingMessage )
6868 setUpdatingCondition (ctx , s .machine , s .updatingReason , s .updatingMessage )
6969 setReadyCondition (ctx , s .machine )
70- setAvailableCondition (ctx , s .machine )
71-
7270 setMachinePhaseAndLastUpdated (ctx , s .machine )
71+
72+ return setAvailableCondition (ctx , s .machine )
7373}
7474
7575func setBootstrapReadyCondition (_ context.Context , machine * clusterv1.Machine , bootstrapConfig * unstructured.Unstructured , bootstrapConfigIsNotFound bool ) {
@@ -774,7 +774,7 @@ func calculateDeletingConditionForSummary(machine *clusterv1.Machine) conditions
774774 }
775775}
776776
777- func setAvailableCondition (ctx context.Context , machine * clusterv1.Machine ) {
777+ func setAvailableCondition (ctx context.Context , machine * clusterv1.Machine ) ctrl. Result {
778778 log := ctrl .LoggerFrom (ctx )
779779 readyCondition := conditions .Get (machine , clusterv1 .MachineReadyCondition )
780780
@@ -788,7 +788,7 @@ func setAvailableCondition(ctx context.Context, machine *clusterv1.Machine) {
788788 Reason : clusterv1 .MachineAvailableInternalErrorReason ,
789789 Message : "Please check controller logs for errors" ,
790790 })
791- return
791+ return ctrl. Result {}
792792 }
793793
794794 if readyCondition .Status != metav1 .ConditionTrue {
@@ -797,23 +797,25 @@ func setAvailableCondition(ctx context.Context, machine *clusterv1.Machine) {
797797 Status : metav1 .ConditionFalse ,
798798 Reason : clusterv1 .MachineNotReadyReason ,
799799 })
800- return
800+ return ctrl. Result {}
801801 }
802802
803- if time .Since (readyCondition .LastTransitionTime .Time ) >= time .Duration (ptr .Deref (machine .Spec .MinReadySeconds , 0 ))* time .Second {
803+ t := time .Since (readyCondition .LastTransitionTime .Time ) - time .Duration (ptr .Deref (machine .Spec .MinReadySeconds , 0 ))* time .Second
804+ if t >= 0 {
804805 conditions .Set (machine , metav1.Condition {
805806 Type : clusterv1 .MachineAvailableCondition ,
806807 Status : metav1 .ConditionTrue ,
807808 Reason : clusterv1 .MachineAvailableReason ,
808809 })
809- return
810+ return ctrl. Result {}
810811 }
811812
812813 conditions .Set (machine , metav1.Condition {
813814 Type : clusterv1 .MachineAvailableCondition ,
814815 Status : metav1 .ConditionFalse ,
815816 Reason : clusterv1 .MachineWaitingForMinReadySecondsReason ,
816817 })
818+ return ctrl.Result {RequeueAfter : - t }
817819}
818820
819821func setMachinePhaseAndLastUpdated (_ context.Context , m * clusterv1.Machine ) {
0 commit comments