Skip to content

Commit

Permalink
fix mhc flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Feb 3, 2023
1 parent 17e2676 commit c71c4f3
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi
return false, 0
}

if conditions.Get(t.Cluster, clusterv1.ControlPlaneInitializedCondition) == nil {
return false, 0
}

// Don't penalize any Machine/Node if the cluster infrastructure is not ready.
if !conditions.IsTrue(t.Cluster, clusterv1.InfrastructureReadyCondition) {
logger.V(3).Info("Not evaluating target health because the cluster infrastructure is not ready")
Expand All @@ -135,18 +139,18 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi
return false, 0
}

controlPlaneInitializedTime := conditions.GetLastTransitionTime(t.Cluster, clusterv1.ControlPlaneInitializedCondition).Time
clusterInfraReadyTime := conditions.GetLastTransitionTime(t.Cluster, clusterv1.InfrastructureReadyCondition).Time
controlPlaneInitialized := conditions.GetLastTransitionTime(t.Cluster, clusterv1.ControlPlaneInitializedCondition)
clusterInfraReady := conditions.GetLastTransitionTime(t.Cluster, clusterv1.InfrastructureReadyCondition)
machineCreationTime := t.Machine.CreationTimestamp.Time

// Use the latest of the 3 times
comparisonTime := machineCreationTime
logger.V(3).Info("Determining comparison time", "machineCreationTime", machineCreationTime, "clusterInfraReadyTime", clusterInfraReadyTime, "controlPlaneInitializedTime", controlPlaneInitializedTime)
if controlPlaneInitializedTime.After(comparisonTime) {
comparisonTime = controlPlaneInitializedTime
logger.V(3).Info("Determining comparison time", "machineCreationTime", machineCreationTime, "clusterInfraReadyTime", clusterInfraReady, "controlPlaneInitializedTime", controlPlaneInitialized)
if controlPlaneInitialized != nil && controlPlaneInitialized.Time.After(comparisonTime) {
comparisonTime = controlPlaneInitialized.Time
}
if clusterInfraReadyTime.After(comparisonTime) {
comparisonTime = clusterInfraReadyTime
if clusterInfraReady != nil && clusterInfraReady.Time.After(comparisonTime) {
comparisonTime = clusterInfraReady.Time
}
logger.V(3).Info("Using comparison time", "time", comparisonTime)

Expand Down

0 comments on commit c71c4f3

Please sign in to comment.