@@ -244,12 +244,11 @@ func modifyControlPlaneViaClusterClassAndWait(ctx context.Context, input modifyC
244
244
// Get the ControlPlane.
245
245
controlPlaneRef := input .Cluster .Spec .ControlPlaneRef
246
246
controlPlaneTopology := input .Cluster .Spec .Topology .ControlPlane
247
- controlPlaneClass := input .ClusterClass .Spec .ControlPlane
248
247
controlPlane , err := external .Get (ctx , mgmtClient , controlPlaneRef , input .ClusterClass .Namespace )
249
248
g .Expect (err ).ToNot (HaveOccurred ())
250
249
251
250
// Verify that the fields from Cluster topology are set on the control plane.
252
- assertControlPlaneFields (g , controlPlane , newControlPlaneTemplate , controlPlaneTopology , controlPlaneClass )
251
+ assertControlPlaneTopologyFields (g , controlPlane , controlPlaneTopology )
253
252
254
253
// Verify that ModifyControlPlaneFields have been set.
255
254
for fieldPath , expectedValue := range input .ModifyControlPlaneFields {
@@ -262,10 +261,10 @@ func modifyControlPlaneViaClusterClassAndWait(ctx context.Context, input modifyC
262
261
}, input .WaitForControlPlane ... ).Should (BeNil ())
263
262
}
264
263
265
- func assertControlPlaneFields ( g Gomega , controlPlane , controlPlaneTemplate * unstructured. Unstructured , controlPlaneTopology clusterv1. ControlPlaneTopology , controlPlaneClass clusterv1. ControlPlaneClass ) {
266
- // Note: We only verify that all labels and annotations from the Cluster topology exist to keep it simple here.
267
- // There could be additional labels and annotations from the ClusterClass or the ControlPlane template .
268
- // This is fully covered by the ClusterClass rollout test.
264
+ // assertControlPlaneTopologyFields asserts that all fields set in the ControlPlaneTopology have been set on the ControlPlane.
265
+ // Note: We intentionally focus on the fields set in the ControlPlaneTopology and ignore the ones set through ClusterClass or
266
+ // ControlPlane template as we want to validate that the fields of the ControlPlaneTopology have been propagated correctly .
267
+ func assertControlPlaneTopologyFields ( g Gomega , controlPlane * unstructured. Unstructured , controlPlaneTopology clusterv1. ControlPlaneTopology ) {
269
268
metadata , err := contract .ControlPlane ().MachineTemplate ().Metadata ().Get (controlPlane )
270
269
g .Expect (err ).ToNot (HaveOccurred ())
271
270
for k , v := range controlPlaneTopology .Metadata .Labels {
@@ -275,41 +274,23 @@ func assertControlPlaneFields(g Gomega, controlPlane, controlPlaneTemplate *unst
275
274
g .Expect (metadata .Annotations ).To (HaveKeyWithValue (k , v ))
276
275
}
277
276
278
- nodeDrainTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeDrainTimeout ().Get (controlPlane )
279
- g .Expect (err ).ToNot (HaveOccurred ())
280
- expectedNodeDrainTimeout := controlPlaneTopology .NodeDrainTimeout
281
- if expectedNodeDrainTimeout == nil {
282
- expectedNodeDrainTimeout = controlPlaneClass .NodeDrainTimeout
283
- }
284
- if expectedNodeDrainTimeout == nil {
285
- expectedNodeDrainTimeout , err = contract .ControlPlaneTemplate ().Template ().MachineTemplate ().NodeDrainTimeout ().Get (controlPlaneTemplate )
277
+ if controlPlaneTopology .NodeDrainTimeout != nil {
278
+ nodeDrainTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeDrainTimeout ().Get (controlPlane )
286
279
g .Expect (err ).ToNot (HaveOccurred ())
280
+ g .Expect (nodeDrainTimeout ).To (Equal (controlPlaneTopology .NodeDrainTimeout ))
287
281
}
288
- g .Expect (nodeDrainTimeout ).To (Equal (expectedNodeDrainTimeout ))
289
282
290
- nodeDeletionTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeDeletionTimeout ().Get (controlPlane )
291
- g .Expect (err ).ToNot (HaveOccurred ())
292
- expectedNodeDeletionTimeout := controlPlaneTopology .NodeDeletionTimeout
293
- if expectedNodeDeletionTimeout == nil {
294
- expectedNodeDeletionTimeout = controlPlaneClass .NodeDeletionTimeout
295
- }
296
- if expectedNodeDeletionTimeout == nil {
297
- expectedNodeDeletionTimeout , err = contract .ControlPlaneTemplate ().Template ().MachineTemplate ().NodeDeletionTimeout ().Get (controlPlaneTemplate )
283
+ if controlPlaneTopology .NodeDeletionTimeout != nil {
284
+ nodeDeletionTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeDeletionTimeout ().Get (controlPlane )
298
285
g .Expect (err ).ToNot (HaveOccurred ())
286
+ g .Expect (nodeDeletionTimeout ).To (Equal (controlPlaneTopology .NodeDeletionTimeout ))
299
287
}
300
- g .Expect (nodeDeletionTimeout ).To (Equal (expectedNodeDeletionTimeout ))
301
288
302
- nodeVolumeDetachTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeVolumeDetachTimeout ().Get (controlPlane )
303
- g .Expect (err ).ToNot (HaveOccurred ())
304
- expectedNodeVolumeDetachTimeout := controlPlaneTopology .NodeVolumeDetachTimeout
305
- if expectedNodeVolumeDetachTimeout == nil {
306
- expectedNodeVolumeDetachTimeout = controlPlaneClass .NodeVolumeDetachTimeout
307
- }
308
- if expectedNodeVolumeDetachTimeout == nil {
309
- expectedNodeVolumeDetachTimeout , err = contract .ControlPlaneTemplate ().Template ().MachineTemplate ().NodeVolumeDetachTimeout ().Get (controlPlaneTemplate )
289
+ if controlPlaneTopology .NodeVolumeDetachTimeout != nil {
290
+ nodeVolumeDetachTimeout , err := contract .ControlPlane ().MachineTemplate ().NodeVolumeDetachTimeout ().Get (controlPlane )
310
291
g .Expect (err ).ToNot (HaveOccurred ())
292
+ g .Expect (nodeVolumeDetachTimeout ).To (Equal (controlPlaneTopology .NodeVolumeDetachTimeout ))
311
293
}
312
- g .Expect (nodeVolumeDetachTimeout ).To (Equal (expectedNodeVolumeDetachTimeout ))
313
294
}
314
295
315
296
// modifyMachineDeploymentViaClusterClassAndWaitInput is the input type for modifyMachineDeploymentViaClusterClassAndWait.
@@ -400,7 +381,7 @@ func modifyMachineDeploymentViaClusterClassAndWait(ctx context.Context, input mo
400
381
md := mdList .Items [0 ]
401
382
402
383
// Verify that the fields from Cluster topology are set on the MachineDeployment.
403
- assertMachineDeploymentFields (g , md , mdTopology , mdClass )
384
+ assertMachineDeploymentTopologyFields (g , md , mdTopology )
404
385
405
386
if mdClass .Template .Bootstrap .Ref != nil {
406
387
// Get the corresponding BootstrapConfigTemplate.
@@ -435,7 +416,10 @@ func modifyMachineDeploymentViaClusterClassAndWait(ctx context.Context, input mo
435
416
}
436
417
}
437
418
438
- func assertMachineDeploymentFields (g Gomega , md clusterv1.MachineDeployment , mdTopology clusterv1.MachineDeploymentTopology , mdClass clusterv1.MachineDeploymentClass ) {
419
+ // assertMachineDeploymentTopologyFields asserts that all fields set in the MachineDeploymentTopology have been set on the MachineDeployment.
420
+ // Note: We intentionally focus on the fields set in the MachineDeploymentTopology and ignore the ones set through ClusterClass
421
+ // as we want to validate that the fields of the MachineDeploymentTopology have been propagated correctly.
422
+ func assertMachineDeploymentTopologyFields (g Gomega , md clusterv1.MachineDeployment , mdTopology clusterv1.MachineDeploymentTopology ) {
439
423
// Note: We only verify that all labels and annotations from the Cluster topology exist to keep it simple here.
440
424
// This is fully covered by the ClusterClass rollout test.
441
425
for k , v := range mdTopology .Metadata .Labels {
@@ -445,41 +429,29 @@ func assertMachineDeploymentFields(g Gomega, md clusterv1.MachineDeployment, mdT
445
429
g .Expect (md .Annotations ).To (HaveKeyWithValue (k , v ))
446
430
}
447
431
448
- expectedNodeDrainTimeout := mdTopology .NodeDrainTimeout
449
- if expectedNodeDrainTimeout == nil {
450
- expectedNodeDrainTimeout = mdClass .NodeDrainTimeout
432
+ if mdTopology .NodeDrainTimeout != nil {
433
+ g .Expect (md .Spec .Template .Spec .NodeDrainTimeout ).To (Equal (mdTopology .NodeDrainTimeout ))
451
434
}
452
- g .Expect (md .Spec .Template .Spec .NodeDrainTimeout ).To (Equal (expectedNodeDrainTimeout ))
453
435
454
- expectedNodeDeletionTimeout := mdTopology .NodeDeletionTimeout
455
- if expectedNodeDeletionTimeout == nil {
456
- expectedNodeDeletionTimeout = mdClass .NodeDeletionTimeout
436
+ if mdTopology .NodeDeletionTimeout != nil {
437
+ g .Expect (md .Spec .Template .Spec .NodeDeletionTimeout ).To (Equal (mdTopology .NodeDeletionTimeout ))
457
438
}
458
- g .Expect (md .Spec .Template .Spec .NodeDeletionTimeout ).To (Equal (expectedNodeDeletionTimeout ))
459
439
460
- expectedNodeVolumeDetachTimeout := mdTopology .NodeVolumeDetachTimeout
461
- if expectedNodeVolumeDetachTimeout == nil {
462
- expectedNodeVolumeDetachTimeout = mdClass .NodeVolumeDetachTimeout
440
+ if mdTopology .NodeVolumeDetachTimeout != nil {
441
+ g .Expect (md .Spec .Template .Spec .NodeVolumeDetachTimeout ).To (Equal (mdTopology .NodeVolumeDetachTimeout ))
463
442
}
464
- g .Expect (md .Spec .Template .Spec .NodeVolumeDetachTimeout ).To (Equal (expectedNodeVolumeDetachTimeout ))
465
443
466
- expectedMinReadySeconds := mdTopology .MinReadySeconds
467
- if expectedMinReadySeconds == nil {
468
- expectedMinReadySeconds = mdClass .MinReadySeconds
444
+ if mdTopology .MinReadySeconds != nil {
445
+ g .Expect (md .Spec .MinReadySeconds ).To (Equal (mdTopology .MinReadySeconds ))
469
446
}
470
- g .Expect (md .Spec .MinReadySeconds ).To (Equal (expectedMinReadySeconds ))
471
447
472
- expectedStrategy := mdTopology .Strategy
473
- if expectedStrategy == nil {
474
- expectedStrategy = mdClass .Strategy
448
+ if mdTopology .Strategy != nil {
449
+ g .Expect (md .Spec .Strategy ).To (Equal (mdTopology .Strategy ))
475
450
}
476
- g .Expect (md .Spec .Strategy ).To (Equal (expectedStrategy ))
477
451
478
- expectedFailureDomain := mdTopology .FailureDomain
479
- if expectedFailureDomain == nil {
480
- expectedFailureDomain = mdClass .FailureDomain
452
+ if mdTopology .FailureDomain != nil {
453
+ g .Expect (md .Spec .Template .Spec .FailureDomain ).To (Equal (mdTopology .FailureDomain ))
481
454
}
482
- g .Expect (md .Spec .Template .Spec .FailureDomain ).To (Equal (expectedFailureDomain ))
483
455
}
484
456
485
457
// rebaseClusterClassAndWaitInput is the input type for rebaseClusterClassAndWait.
0 commit comments