@@ -70,7 +70,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:MachineConfigNodes]", func() {
70
70
func ValidateMCNProperties (oc * exutil.CLI , fixture string ) {
71
71
// Create client set for test
72
72
clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
73
- o .Expect (clientErr ).NotTo (o .HaveOccurred ())
73
+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
74
74
75
75
// Grab a random node from each default pool
76
76
workerNode := GetRandomNode (oc , worker )
@@ -92,13 +92,13 @@ func ValidateMCNProperties(oc *exutil.CLI, fixture string) {
92
92
defer func () {
93
93
// Get starting state of default worker MCP
94
94
workerMcp , err := clientSet .MachineconfigurationV1 ().MachineConfigPools ().Get (context .TODO (), worker , metav1.GetOptions {})
95
- o .Expect (err ).NotTo (o .HaveOccurred ())
95
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Could not get worker MCP." )
96
96
workerMcpReadyMachines := workerMcp .Status .ReadyMachineCount
97
97
98
98
// Unlabel node
99
99
framework .Logf ("Removing label node-role.kubernetes.io/%v from node %v" , custom , workerNode .Name )
100
100
unlabelErr := oc .Run ("label" ).Args (fmt .Sprintf ("node/%s" , workerNode .Name ), fmt .Sprintf ("node-role.kubernetes.io/%s-" , custom )).Execute ()
101
- o .Expect (unlabelErr ).NotTo (o .HaveOccurred ())
101
+ o .Expect (unlabelErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Could not remove label 'node-role.kubernetes.io/%s' from node '%v'." , custom , workerNode . Name ) )
102
102
103
103
// Wait for infra pool to report no nodes & for worker MCP to be ready
104
104
framework .Logf ("Waiting for %v MCP to be updated with %v ready machines." , custom , 0 )
@@ -109,22 +109,22 @@ func ValidateMCNProperties(oc *exutil.CLI, fixture string) {
109
109
// Delete custom MCP
110
110
framework .Logf ("Deleting MCP %v" , custom )
111
111
deleteMCPErr := oc .Run ("delete" ).Args ("mcp" , custom ).Execute ()
112
- o .Expect (deleteMCPErr ).NotTo (o .HaveOccurred ())
112
+ o .Expect (deleteMCPErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error deleting MCP '%v': %v" , custom , deleteMCPErr ) )
113
113
}()
114
114
115
115
// Apply the fixture to create a custom MCP called "infra" & label the worker node accordingly
116
116
mcpErr := oc .Run ("apply" ).Args ("-f" , fixture ).Execute ()
117
- o .Expect (mcpErr ).NotTo (o .HaveOccurred ())
117
+ o .Expect (mcpErr ).NotTo (o .HaveOccurred (), "Could not create custom MCP." )
118
118
labelErr := oc .Run ("label" ).Args (fmt .Sprintf ("node/%s" , workerNode .Name ), fmt .Sprintf ("node-role.kubernetes.io/%s=" , custom )).Execute ()
119
- o .Expect (labelErr ).NotTo (o .HaveOccurred ())
119
+ o .Expect (labelErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Could not add label 'node-role.kubernetes.io/%s' to node '%v'." , custom , workerNode . Name ) )
120
120
121
121
// Wait for the custom pool to be updated with the node ready
122
122
framework .Logf ("Waiting for '%v' MCP to be updated with %v ready machines." , custom , 1 )
123
123
WaitForMCPToBeReady (oc , clientSet , custom , 1 )
124
124
125
- // Get node desired and current config versions
125
+ // Get node in custom pool
126
126
customNodes , customNodeErr := GetNodesByRole (oc , custom )
127
- o .Expect (customNodeErr ).NotTo (o .HaveOccurred ())
127
+ o .Expect (customNodeErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Could not get node in MCP '%v'." , custom ) )
128
128
customNode := customNodes [0 ]
129
129
130
130
// Validate MCN for node in custom pool
@@ -139,7 +139,7 @@ func ValidateMCNProperties(oc *exutil.CLI, fixture string) {
139
139
func ValidateMCNPropertiesSNO (oc * exutil.CLI , fixture string ) {
140
140
// Create client set for test
141
141
clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
142
- o .Expect (clientErr ).NotTo (o .HaveOccurred ())
142
+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
143
143
144
144
// Grab the cluster's node
145
145
node := GetRandomNode (oc , master )
@@ -155,21 +155,21 @@ func ValidateMCNPropertiesSNO(oc *exutil.CLI, fixture string) {
155
155
func ValidateMCNConditionTransitions (oc * exutil.CLI , fixture string ) {
156
156
// Create client set for test
157
157
clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
158
- o .Expect (clientErr ).NotTo (o .HaveOccurred ())
158
+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
159
159
160
160
// Delete MC on failure or test completion
161
161
defer func () {
162
162
deleteMCErr := oc .Run ("delete" ).Args ("machineconfig" , "90-master-testfile" ).Execute ()
163
- o .Expect (deleteMCErr ).NotTo (o .HaveOccurred ())
163
+ o .Expect (deleteMCErr ).NotTo (o .HaveOccurred (), "Could not delete MachineConfig '90-master-testfile'." )
164
164
}()
165
165
166
166
// Apply MC targeting master pool
167
167
mcErr := oc .Run ("apply" ).Args ("-f" , fixture ).Execute ()
168
- o .Expect (mcErr ).NotTo (o .HaveOccurred ())
168
+ o .Expect (mcErr ).NotTo (o .HaveOccurred (), "Could not apply MachineConfig." )
169
169
170
170
// Get an updating master node
171
171
updatingNodes := GetCordonedNodes (oc , master )
172
- o .Expect (len (updatingNodes ) > 0 , "No ready nodes found for MCP '%v'." , master )
172
+ o .Expect (len (updatingNodes ) > 0 , fmt . Sprintf ( "No ready nodes found for MCP '%v'." , master ) )
173
173
masterNode := updatingNodes [0 ]
174
174
175
175
// Validate transition through conditions for MCN
@@ -178,37 +178,37 @@ func ValidateMCNConditionTransitions(oc *exutil.CLI, fixture string) {
178
178
// a warning will be logged instead of erroring out the test.
179
179
framework .Logf ("Waiting for Updated=False" )
180
180
err := WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdated , metav1 .ConditionFalse , 1 * time .Minute , 1 * time .Second )
181
- o .Expect (err ).NotTo (o .HaveOccurred ())
181
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Updated=False." )
182
182
framework .Logf ("Waiting for UpdatePrepared=True" )
183
183
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdatePrepared , metav1 .ConditionTrue , 1 * time .Minute , 1 * time .Second )
184
- o .Expect (err ).NotTo (o .HaveOccurred ())
184
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect UpdatePrepared=True." )
185
185
framework .Logf ("Waiting for UpdateExecuted=Unknown" )
186
186
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateExecuted , metav1 .ConditionUnknown , 30 * time .Second , 1 * time .Second )
187
187
if err != nil {
188
188
framework .Logf ("Warning, could not detect UpdateExecuted=Unknown." )
189
189
}
190
190
framework .Logf ("Waiting for Cordoned=True" )
191
191
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateCordoned , metav1 .ConditionTrue , 30 * time .Second , 1 * time .Second )
192
- o .Expect (err ).NotTo (o .HaveOccurred ())
192
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Cordoned=True." )
193
193
framework .Logf ("Waiting for Drained=Unknown" )
194
194
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateDrained , metav1 .ConditionUnknown , 15 * time .Second , 1 * time .Second )
195
195
if err != nil {
196
196
framework .Logf ("Warning, could not detect Drained=Unknown." )
197
197
}
198
198
framework .Logf ("Waiting for Drained=True" )
199
199
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateDrained , metav1 .ConditionTrue , 4 * time .Minute , 1 * time .Second )
200
- o .Expect (err ).NotTo (o .HaveOccurred ())
200
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Drained=True." )
201
201
framework .Logf ("Waiting for AppliedFilesAndOS=Unknown" )
202
202
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateFilesAndOS , metav1 .ConditionUnknown , 30 * time .Second , 1 * time .Second )
203
203
if err != nil {
204
204
framework .Logf ("Warning, could not detect AppliedFilesAndOS=Unknown." )
205
205
}
206
206
framework .Logf ("Waiting for AppliedFilesAndOS=True" )
207
207
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateFilesAndOS , metav1 .ConditionTrue , 3 * time .Minute , 1 * time .Second )
208
- o .Expect (err ).NotTo (o .HaveOccurred ())
208
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect AppliedFilesAndOS=True." )
209
209
framework .Logf ("Waiting for UpdateExecuted=True" )
210
210
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateExecuted , metav1 .ConditionTrue , 20 * time .Second , 1 * time .Second )
211
- o .Expect (err ).NotTo (o .HaveOccurred ())
211
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect UpdateExecuted=True." )
212
212
framework .Logf ("Waiting for UpdatePostActionComplete=Unknown" )
213
213
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdatePostActionComplete , metav1 .ConditionUnknown , 30 * time .Second , 1 * time .Second )
214
214
if err != nil {
@@ -221,30 +221,30 @@ func ValidateMCNConditionTransitions(oc *exutil.CLI, fixture string) {
221
221
}
222
222
framework .Logf ("Waiting for RebootedNode=True" )
223
223
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateRebooted , metav1 .ConditionTrue , 5 * time .Minute , 1 * time .Second )
224
- o .Expect (err ).NotTo (o .HaveOccurred ())
224
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect RebootedNode=True." )
225
225
framework .Logf ("Waiting for Resumed=True" )
226
226
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeResumed , metav1 .ConditionTrue , 15 * time .Second , 1 * time .Second )
227
- o .Expect (err ).NotTo (o .HaveOccurred ())
227
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Resumed=True." )
228
228
framework .Logf ("Waiting for UpdateComplete=True" )
229
229
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateComplete , metav1 .ConditionTrue , 10 * time .Second , 1 * time .Second )
230
- o .Expect (err ).NotTo (o .HaveOccurred ())
230
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect UpdateComplete=True." )
231
231
framework .Logf ("Waiting for Uncordoned=True" )
232
232
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdateUncordoned , metav1 .ConditionTrue , 10 * time .Second , 1 * time .Second )
233
- o .Expect (err ).NotTo (o .HaveOccurred ())
233
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Uncordoned=True." )
234
234
framework .Logf ("Waiting for Updated=True" )
235
235
err = WaitForMCNConditionStatus (clientSet , masterNode .Name , mcfgv1alpha1 .MachineConfigNodeUpdated , metav1 .ConditionTrue , 1 * time .Minute , 1 * time .Second )
236
- o .Expect (err ).NotTo (o .HaveOccurred ())
236
+ o .Expect (err ).NotTo (o .HaveOccurred (), "Error, could not detect Updated=True." )
237
237
238
238
// When an update is complete, all conditions other than `Updated` must be false
239
239
framework .Logf ("Checking all conditions other than 'Updated' are False." )
240
- o .Expect (ConfirmUpdatedMCNStatus (clientSet , masterNode .Name )).Should (o .BeTrue ())
240
+ o .Expect (ConfirmUpdatedMCNStatus (clientSet , masterNode .Name )).Should (o .BeTrue (), "Error, all conditions must be 'False' when Updated=True." )
241
241
}
242
242
243
243
// `ValidateMCNConditionOnNodeDegrade` checks that Conditions properly update on a node failure (MCP degrade)
244
244
func ValidateMCNConditionOnNodeDegrade (oc * exutil.CLI , fixture string , isSno bool ) {
245
245
// Create client set for test
246
246
clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
247
- o .Expect (clientErr ).NotTo (o .HaveOccurred ())
247
+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
248
248
249
249
// In SNO, master pool will degrade
250
250
poolName := worker
@@ -258,33 +258,34 @@ func ValidateMCNConditionOnNodeDegrade(oc *exutil.CLI, fixture string, isSno boo
258
258
defer func () {
259
259
// Delete the applied MC
260
260
deleteMCErr := oc .Run ("delete" ).Args ("machineconfig" , mcName ).Execute ()
261
- o .Expect (deleteMCErr ).NotTo (o .HaveOccurred ())
261
+ o .Expect (deleteMCErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Could not delete MachineConfig '%v'." , mcName ) )
262
262
263
263
// Recover the degraded MCP
264
264
recoverErr := RecoverFromDegraded (oc , poolName )
265
- o .Expect (recoverErr ).NotTo (o .HaveOccurred ())
265
+ o .Expect (recoverErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Could not recover MCP '%v' from degraded state." , poolName ) )
266
266
}()
267
267
268
268
// Apply invalid MC
269
269
mcErr := oc .Run ("apply" ).Args ("-f" , fixture ).Execute ()
270
- o .Expect (mcErr ).NotTo (o .HaveOccurred ())
270
+ o .Expect (mcErr ).NotTo (o .HaveOccurred (), "Could not apply MachineConfig." )
271
271
272
272
// Wait for MCP to be in a degraded state with one degraded machine
273
- o .Expect (WaitForMCPConditionStatus (oc , poolName , "Degraded" , corev1 .ConditionTrue , 8 * time .Minute , 3 * time .Second )).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error waiting for '%v' MCP to be in a degraded state." , poolName ))
273
+ degradedErr := WaitForMCPConditionStatus (oc , poolName , "Degraded" , corev1 .ConditionTrue , 8 * time .Minute , 3 * time .Second )
274
+ o .Expect (degradedErr ).NotTo (o .HaveOccurred (), fmt .Sprintf ("Error waiting for '%v' MCP to be in a degraded state." , poolName ))
274
275
mcp , err := clientSet .MachineconfigurationV1 ().MachineConfigPools ().Get (context .TODO (), poolName , metav1.GetOptions {})
275
- o .Expect (err ).NotTo (o .HaveOccurred (), "Error getting '%v' MCP." , poolName )
276
+ o .Expect (err ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error getting '%v' MCP." , poolName ) )
276
277
o .Expect (mcp .Status .DegradedMachineCount ).To (o .BeNumerically ("==" , 1 ), fmt .Sprintf ("Degraded machine count is not 1. It is %v." , mcp .Status .DegradedMachineCount ))
277
278
278
279
// Get degraded node
279
280
degradedNode , degradedNodeErr := GetDegradedNode (oc , poolName )
280
- o .Expect (degradedNodeErr ).NotTo (o .HaveOccurred ())
281
+ o .Expect (degradedNodeErr ).NotTo (o .HaveOccurred (), "Could not get degraded node." )
281
282
282
283
// Validate MCN of degraded node
283
284
degradedNodeMCN , degradedErr := clientSet .MachineconfigurationV1alpha1 ().MachineConfigNodes ().Get (context .TODO (), degradedNode .Name , metav1.GetOptions {})
284
- o .Expect (degradedErr ).NotTo (o .HaveOccurred ())
285
+ o .Expect (degradedErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error getting MCN of degraded node '%v'." , degradedNode . Name ) )
285
286
framework .Logf ("Validating that `AppliedFilesAndOS` and `UpdateExecuted` conditions in '%v' MCN have a status of 'Unknown'." , degradedNodeMCN .Name )
286
- o .Expect (CheckMCNConditionStatus (degradedNodeMCN , mcfgv1alpha1 .MachineConfigNodeUpdateFilesAndOS , metav1 .ConditionUnknown ))
287
- o .Expect (CheckMCNConditionStatus (degradedNodeMCN , mcfgv1alpha1 .MachineConfigNodeUpdateExecuted , metav1 .ConditionUnknown ))
287
+ o .Expect (CheckMCNConditionStatus (degradedNodeMCN , mcfgv1alpha1 .MachineConfigNodeUpdateFilesAndOS , metav1 .ConditionUnknown )). Should ( o . BeTrue (), "Condition 'AppliedFilesAndOS' does not have the expected status of 'Unknown'." )
288
+ o .Expect (CheckMCNConditionStatus (degradedNodeMCN , mcfgv1alpha1 .MachineConfigNodeUpdateExecuted , metav1 .ConditionUnknown )). Should ( o . BeTrue (), "Condition 'UpdateExecuted' does not have the expected status of 'Unknown'." )
288
289
}
289
290
290
291
// `ValidateMCNProperties` checks that MCNs with correct properties are created on node creation
@@ -296,15 +297,15 @@ func ValidateMCNOnNodeCreationAndDeletion(oc *exutil.CLI) {
296
297
297
298
// Create machine client for test
298
299
machineClient , machineErr := machineclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
299
- o .Expect (machineErr ).NotTo (o .HaveOccurred ())
300
+ o .Expect (machineErr ).NotTo (o .HaveOccurred (), "Error creating machine client for test." )
300
301
301
302
// Create client set for test
302
303
clientSet , clientErr := machineconfigclient .NewForConfig (oc .KubeFramework ().ClientConfig ())
303
- o .Expect (clientErr ).NotTo (o .HaveOccurred ())
304
+ o .Expect (clientErr ).NotTo (o .HaveOccurred (), "Error creating client set for test." )
304
305
305
306
// Skip test if worker nodes cannot be scaled
306
307
canBeScaled , canScaleErr := WorkersCanBeScaled (oc , machineClient )
307
- o .Expect (canScaleErr ).NotTo (o .HaveOccurred ())
308
+ o .Expect (canScaleErr ).NotTo (o .HaveOccurred (), "Error occured when determining whether worker nodes can be scaled." )
308
309
if ! canBeScaled {
309
310
g .Skip ("Worker nodes cannot be scaled using MachineSets. This test cannot be executed if workers cannot be scaled via MachineSets." )
310
311
}
@@ -325,7 +326,7 @@ func ValidateMCNOnNodeCreationAndDeletion(oc *exutil.CLI) {
325
326
// original value, when needed (in the case where the replica value patch was successful).
326
327
defer func () {
327
328
cleanupErr := ScaleMachineSetDown (oc , machineSet , originalReplica , cleanupCompleted )
328
- o .Expect (cleanupErr ).NotTo (o .HaveOccurred ())
329
+ o .Expect (cleanupErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error cleaning up cluster by scaling down MachineSet '%v'." , machineSet . Name ) )
329
330
cleanupCompleted = true
330
331
}()
331
332
@@ -339,7 +340,7 @@ func ValidateMCNOnNodeCreationAndDeletion(oc *exutil.CLI) {
339
340
// original value and ensuring that the newly provisioned Machine is deleted.
340
341
defer func () {
341
342
cleanupErr := CleanupProvisionedMachine (oc , machineClient , machineSet .Name , originalReplica , newMachineName , cleanupCompleted )
342
- o .Expect (cleanupErr ).NotTo (o .HaveOccurred ())
343
+ o .Expect (cleanupErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error removing provisioned Machine '%v' by scaling down MachineSet '%v'." , newMachineName , machineSet . Name ) )
343
344
cleanupCompleted = true
344
345
}()
345
346
@@ -362,13 +363,13 @@ func ValidateMCNOnNodeCreationAndDeletion(oc *exutil.CLI) {
362
363
// original value and ensuring that the newly created Node is deleted.
363
364
defer func () {
364
365
cleanupErr := CleanupCreatedNode (oc , newMachineName , originalReplica , newNode .Name , cleanupCompleted )
365
- o .Expect (cleanupErr ).NotTo (o .HaveOccurred ())
366
+ o .Expect (cleanupErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "Error removing created Node '%v' by scaling down MachineSet '%v'." , newNode . Name , machineSet . Name ) )
366
367
cleanupCompleted = true
367
368
}()
368
369
369
370
// Validate new MCN
370
371
validMCNErr := WaitForValidMCNProperties (clientSet , newNode )
371
- o .Expect (validMCNErr ).NotTo (o .HaveOccurred ())
372
+ o .Expect (validMCNErr ).NotTo (o .HaveOccurred (), fmt . Sprintf ( "MCN for node '%v' has invalid properties." , newNode ) )
372
373
373
374
// Scale down the MachineSet to delete the created node
374
375
framework .Logf ("Scaling down MachineSet to delete node." )
0 commit comments