Skip to content

Commit fd7e9bb

Browse files
isabella-janssenopenshift-cherrypick-robot
authored andcommitted
mco: make MCN condition validation more robust against fast transitions
1 parent 9992bc5 commit fd7e9bb

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

test/extended/machine_config/helpers.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,10 @@ func WaitForMCPConditionStatus(oc *exutil.CLI, mcpName string, conditionType mcf
762762
return nil
763763
}
764764

765-
// `WaitForMCNConditionStatus` waits up to a specified timeout for the desired MCN condition to match the desired status (ex. wait until "Updated" is "False")
765+
// `WaitForMCNConditionStatus` waits up to a specified timeout for the desired MCN condition to
766+
// match the desired status (ex. wait until "Updated" is "False"). If the desired condition is
767+
// "Unknown," the function will also return true if the condition is "True," which ensures that we
768+
// do not fail when an update progresses quickly through the intermediary "Unknown" phase.
766769
func WaitForMCNConditionStatus(clientSet *machineconfigclient.Clientset, mcnName string, conditionType mcfgv1.StateProgress, status metav1.ConditionStatus,
767770
timeout time.Duration, interval time.Duration) (bool, error) {
768771

@@ -781,6 +784,12 @@ func WaitForMCNConditionStatus(clientSet *machineconfigclient.Clientset, mcnName
781784

782785
// Check if the MCN status is as desired
783786
conditionMet = CheckMCNConditionStatus(workerNodeMCN, conditionType, status)
787+
// If the condition was not met and we are expecting it may have transitioned quickly
788+
// trough the "Unknown" phase, check if the condition has flipped to `True`.
789+
if !conditionMet && status == metav1.ConditionUnknown {
790+
conditionMet = CheckMCNConditionStatus(workerNodeMCN, conditionType, metav1.ConditionTrue)
791+
framework.Logf("MCN '%v' %v condition was %v, missed transition through %v.", mcnName, conditionType, metav1.ConditionTrue, status)
792+
}
784793
return conditionMet, nil
785794
}); err != nil {
786795
framework.Logf("The desired MCN condition was never met: %v", err)

test/extended/machine_config/machine_config_node.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:MachineConfigNodes]", func() {
8888

8989
// When the cluster has machines in the "worker" MCP, use a custom MCP to test the update
9090
if slices.Contains(poolNames, worker) {
91+
framework.Logf("Validating MCN properties in custom MCP.")
9192
ValidateMCNConditionTransitionsOnRebootlessUpdate(oc, clientSet, nodeDisruptionFixture, nodeDisruptionEmptyFixture, customMCFixture, infraMCPFixture)
9293
} else { // When there are no machines in the "worker" MCP, test the update by applying a MC targeting the "master" MCP
94+
framework.Logf("Validating MCN properties in master MCP.")
9395
ValidateMCNConditionTransitionsOnRebootlessUpdateMaster(oc, clientSet, nodeDisruptionFixture, nodeDisruptionEmptyFixture, masterMCFixture)
9496
}
9597
})
@@ -303,9 +305,7 @@ func validateTransitionThroughConditions(clientSet *machineconfigclient.Clientse
303305
framework.Logf("Waiting for UpdateExecuted=Unknown")
304306
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateExecuted, metav1.ConditionUnknown, 30*time.Second, 1*time.Second)
305307
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Error occured while waiting for UpdateExecuted=Unknown: %v", err))
306-
if !conditionMet {
307-
framework.Logf("Warning, could not detect UpdateExecuted=Unknown.")
308-
}
308+
o.Expect(conditionMet).To(o.BeTrue(), "Error, could not detect UpdateExecuted=Unknown.")
309309

310310
// On standard, non-rebootless, update, check that node transitions through "Cordoned" and "Drained" phases
311311
if !isRebootless {
@@ -317,9 +317,7 @@ func validateTransitionThroughConditions(clientSet *machineconfigclient.Clientse
317317
framework.Logf("Waiting for Drained=Unknown")
318318
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateDrained, metav1.ConditionUnknown, 15*time.Second, 1*time.Second)
319319
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Error occured while waiting for Drained=Unknown: %v", err))
320-
if !conditionMet {
321-
framework.Logf("Warning, could not detect Drained=Unknown.")
322-
}
320+
o.Expect(conditionMet).To(o.BeTrue(), "Error, could not detect Drained=Unknown.")
323321

324322
framework.Logf("Waiting for Drained=True")
325323
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateDrained, metav1.ConditionTrue, 4*time.Minute, 1*time.Second)
@@ -330,9 +328,7 @@ func validateTransitionThroughConditions(clientSet *machineconfigclient.Clientse
330328
framework.Logf("Waiting for AppliedFilesAndOS=Unknown")
331329
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateFilesAndOS, metav1.ConditionUnknown, 30*time.Second, 1*time.Second)
332330
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Error occured while waiting for AppliedFilesAndOS=Unknown: %v", err))
333-
if !conditionMet {
334-
framework.Logf("Warning, could not detect AppliedFilesAndOS=Unknown.")
335-
}
331+
o.Expect(conditionMet).To(o.BeTrue(), "Error, could not detect AppliedFilesAndOS=Unknown.")
336332

337333
framework.Logf("Waiting for AppliedFilesAndOS=True")
338334
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateFilesAndOS, metav1.ConditionTrue, 3*time.Minute, 1*time.Second)
@@ -354,9 +350,7 @@ func validateTransitionThroughConditions(clientSet *machineconfigclient.Clientse
354350
framework.Logf("Waiting for RebootedNode=Unknown")
355351
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateRebooted, metav1.ConditionUnknown, 15*time.Second, 1*time.Second)
356352
o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Error occured while waiting for RebootedNode=Unknown: %v", err))
357-
if !conditionMet {
358-
framework.Logf("Warning, could not detect RebootedNode=Unknown.")
359-
}
353+
o.Expect(conditionMet).To(o.BeTrue(), "Error, could not detect RebootedNode=Unknown.")
360354

361355
framework.Logf("Waiting for RebootedNode=True")
362356
conditionMet, err = WaitForMCNConditionStatus(clientSet, updatingNodeName, mcfgv1.MachineConfigNodeUpdateRebooted, metav1.ConditionTrue, 6*time.Minute, 1*time.Second)

0 commit comments

Comments
 (0)