66 "fmt"
77 "os/exec"
88 "path/filepath"
9+ "slices"
910 "time"
1011
1112 mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
@@ -77,10 +78,19 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:MachineConfigNodes]", func() {
7778 // regression tests handle the different conditions list.
7879 SkipWhenFeatureGateEnabled (oc .AdminConfigClient (), "ImageModeStatusReporting" )
7980
80- if IsSingleNode (oc ) {
81- ValidateMCNConditionTransitionsOnRebootlessUpdateSNO (oc , nodeDisruptionFixture , nodeDisruptionEmptyFixture , masterMCFixture )
82- } else {
83- ValidateMCNConditionTransitionsOnRebootlessUpdate (oc , nodeDisruptionFixture , nodeDisruptionEmptyFixture , customMCFixture , infraMCPFixture )
81+ // Create client set for test
82+ clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
83+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
84+
85+ // Get MCPs to test for cluster
86+ poolNames := GetRolesToTest (oc , clientSet )
87+ framework .Logf ("Validating MCN properties for node(s) in pool(s) '%v'." , poolNames )
88+
89+ // When the cluster has machines in the "worker" MCP, use a custom MCP to test the update
90+ if slices .Contains (poolNames , worker ) {
91+ ValidateMCNConditionTransitionsOnRebootlessUpdate (oc , clientSet , nodeDisruptionFixture , nodeDisruptionEmptyFixture , customMCFixture , infraMCPFixture )
92+ } else { // When there are no machines in the "worker" MCP, test the update by applying a MC targeting the "master" MCP
93+ ValidateMCNConditionTransitionsOnRebootlessUpdateMaster (oc , clientSet , nodeDisruptionFixture , nodeDisruptionEmptyFixture , masterMCFixture )
8494 }
8595 })
8696
@@ -168,17 +178,17 @@ func ValidateMCNPropertiesCustomMCP(oc *exutil.CLI, fixture string) {
168178 o .Expect (mcnErr ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error validating MCN properties node in custom pool '%v'." , custom ))
169179}
170180
171- // `ValidateMCNConditionTransitions` checks that Conditions properly update on a node update
172- // Note that a custom MCP is created for this test to limit the number of upgrading nodes &
173- // decrease cleanup time.
174- func ValidateMCNConditionTransitionsOnRebootlessUpdate (oc * exutil.CLI , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string , mcpFixture string ) {
181+ // `ValidateMCNConditionTransitionsOnRebootlessUpdate` checks that the `Conditions` in an MCN
182+ // properly update on a node update in a custom MCP. The steps of this function are:
183+ // 1. Apply a node disruption policy
184+ // 2. Create a custom MCP with one node
185+ // 3. Apply a MC
186+ // 4. Validate the MCN conditions transition as expected throughout the update
187+ // 5. Clean up the test resources
188+ func ValidateMCNConditionTransitionsOnRebootlessUpdate (oc * exutil.CLI , clientSet * machineconfigclient.Clientset , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string , mcpFixture string ) {
175189 poolName := custom
176190 mcName := fmt .Sprintf ("90-%v-testfile" , poolName )
177191
178- // Create client set for test
179- clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
180- o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
181-
182192 // Grab a random worker node
183193 workerNode := GetRandomNode (oc , worker )
184194 o .Expect (workerNode .Name ).NotTo (o .Equal ("" ), "Could not get a worker node." )
@@ -218,16 +228,17 @@ func ValidateMCNConditionTransitionsOnRebootlessUpdate(oc *exutil.CLI, nodeDisru
218228 o .Expect (ConfirmUpdatedMCNStatus (clientSet , updatingNodeName )).Should (o .BeTrue (), "Error, all conditions must be 'False' when Updated=True." )
219229}
220230
221- // `ValidateMCNConditionTransitionsSNO` checks that Conditions properly update on a node update
222- // in Single Node Openshift
223- func ValidateMCNConditionTransitionsOnRebootlessUpdateSNO (oc * exutil.CLI , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string ) {
231+ // `ValidateMCNConditionTransitionsOnRebootlessUpdateMaster` checks that the `Conditions` in an MCN
232+ // properly update on a node update in the master MCP. The steps of this function are:
233+ // 1. Apply a node disruption policy
234+ // 2. Apply a MC
235+ // 3. Get the updating node
236+ // 4. Validate the MCN conditions transition as expected throughout the update
237+ // 5. Clean up the test resources
238+ func ValidateMCNConditionTransitionsOnRebootlessUpdateMaster (oc * exutil.CLI , clientSet * machineconfigclient.Clientset , nodeDisruptionFixture string , nodeDisruptionEmptyFixture string , mcFixture string ) {
224239 poolName := master
225240 mcName := fmt .Sprintf ("90-%v-testfile" , poolName )
226241
227- // Create client set for test
228- clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
229- o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
230-
231242 // Remove node disruption policy on test completion or failure
232243 defer func () {
233244 // Apply empty MachineConfiguration fixture to remove previously set NodeDisruptionPolicy
@@ -251,12 +262,13 @@ func ValidateMCNConditionTransitionsOnRebootlessUpdateSNO(oc *exutil.CLI, nodeDi
251262 WaitForMCPToBeReady (oc , clientSet , poolName , 1 )
252263 }()
253264
254- // Apply MC targeting worker node
265+ // Apply MC targeting master MCP
255266 mcErr := oc .Run ("apply" ).Args ("-f" , mcFixture ).Execute ()
256267 o .Expect (mcErr ).NotTo (o .HaveOccurred (), "Could not apply MachineConfig." )
257268
258269 // Get the updating node
259- updatingNode := GetUpdatingNodeSNO (oc , poolName )
270+ updatingNode := GetCordonedNode (oc , poolName )
271+ o .Expect (updatingNode ).NotTo (o .BeNil (), "Could not get updating node." )
260272 framework .Logf ("Node '%v' is updating." , updatingNode .Name )
261273
262274 // Validate transition through conditions for MCN
0 commit comments