@@ -472,28 +472,39 @@ func TestMachineSetReconciler(t *testing.T) {
472472 }
473473
474474 // Verify that in-place mutable fields propagate from MachineSet to Machines.
475- t .Log ("Updating NodeDrainTimeoutSeconds on MachineSet" )
475+ t .Log ("Updating NodeDrainTimeoutSeconds and Taints on MachineSet" )
476476 patchHelper , err := patch .NewHelper (instance , env )
477477 g .Expect (err ).ToNot (HaveOccurred ())
478478 instance .Spec .Template .Spec .Deletion .NodeDrainTimeoutSeconds = duration5m
479+ additionalTaint := clusterv1.MachineTaint {
480+ Key : "additional-taint-key" ,
481+ Value : "additional-taint-value" ,
482+ Effect : corev1 .TaintEffectNoSchedule ,
483+ Propagation : clusterv1 .MachineTaintPropagationAlways ,
484+ }
485+ instance .Spec .Template .Spec .Taints = []clusterv1.MachineTaint {additionalTaint }
479486 g .Expect (patchHelper .Patch (ctx , instance )).Should (Succeed ())
480487
481488 t .Log ("Verifying new NodeDrainTimeoutSeconds value is set on Machines" )
482489 g .Eventually (func () bool {
483490 if err := env .List (ctx , machines , client .InNamespace (namespace .Name )); err != nil {
484491 return false
485492 }
486- // All the machines should have the new NodeDrainTimeoutValue
493+ // All the machines should have the new NodeDrainTimeoutValue and the new taint
487494 for _ , m := range machines .Items {
488495 if m .Spec .Deletion .NodeDrainTimeoutSeconds == nil {
489496 return false
490497 }
491498 if * m .Spec .Deletion .NodeDrainTimeoutSeconds != * duration5m {
492499 return false
493500 }
501+ if len (m .Spec .Taints ) != 1 || m .Spec .Taints [0 ].Key != additionalTaint .Key ||
502+ m .Spec .Taints [0 ].Value != additionalTaint .Value || m .Spec .Taints [0 ].Effect != additionalTaint .Effect {
503+ return false
504+ }
494505 }
495506 return true
496- }, timeout ).Should (BeTrue (), "machine should have the updated NodeDrainTimeoutSeconds value " )
507+ }, timeout ).Should (BeTrue (), "machine should have the updated NodeDrainTimeoutSeconds and Taints values " )
497508
498509 // Try to delete 1 machine and check the MachineSet scales back up.
499510 machineToBeDeleted := machines .Items [0 ]
@@ -3528,6 +3539,19 @@ func TestComputeDesiredMachine(t *testing.T) {
35283539 duration5s := ptr .To (int32 (5 ))
35293540 duration10s := ptr .To (int32 (10 ))
35303541
3542+ machineTaint := clusterv1.MachineTaint {
3543+ Key : "taint-key" ,
3544+ Value : "taint-value" ,
3545+ Effect : corev1 .TaintEffectNoSchedule ,
3546+ Propagation : clusterv1 .MachineTaintPropagationAlways ,
3547+ }
3548+ changedMachineTaint := clusterv1.MachineTaint {
3549+ Key : "changed-taint-key" ,
3550+ Value : "changed-taint-value" ,
3551+ Effect : corev1 .TaintEffectNoSchedule ,
3552+ Propagation : clusterv1 .MachineTaintPropagationAlways ,
3553+ }
3554+
35313555 namingTemplateKey := "-md"
35323556 mdName := "testmd"
35333557 msName := "ms1"
@@ -3567,6 +3591,9 @@ func TestComputeDesiredMachine(t *testing.T) {
35673591 NodeDeletionTimeoutSeconds : duration10s ,
35683592 },
35693593 MinReadySeconds : ptr.To [int32 ](10 ),
3594+ Taints : []clusterv1.MachineTaint {
3595+ machineTaint ,
3596+ },
35703597 },
35713598 }
35723599
@@ -3590,6 +3617,7 @@ func TestComputeDesiredMachine(t *testing.T) {
35903617 NodeDeletionTimeoutSeconds : duration10s ,
35913618 },
35923619 MinReadySeconds : ptr.To [int32 ](10 ),
3620+ Taints : []clusterv1.MachineTaint {machineTaint },
35933621 },
35943622 }
35953623
@@ -3618,6 +3646,7 @@ func TestComputeDesiredMachine(t *testing.T) {
36183646 existingMachine .Spec .Deletion .NodeDeletionTimeoutSeconds = duration5s
36193647 existingMachine .Spec .Deletion .NodeVolumeDetachTimeoutSeconds = duration5s
36203648 existingMachine .Spec .MinReadySeconds = ptr.To [int32 ](5 )
3649+ existingMachine .Spec .Taints = []clusterv1.MachineTaint {changedMachineTaint }
36213650
36223651 expectedUpdatedMachine := skeletonMachine .DeepCopy ()
36233652 expectedUpdatedMachine .Name = existingMachine .Name
0 commit comments