@@ -508,13 +508,11 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
508508 }
509509
510510 tests := []struct {
511- name string
512- kcp * controlplanev1.KubeadmControlPlane
513- isUpdatingExistingMachine bool
514- existingClusterConfigurationAnnotation string
515- want []gomegatypes.GomegaMatcher
516- wantClusterConfigurationAnnotation string
517- wantErr bool
511+ name string
512+ kcp * controlplanev1.KubeadmControlPlane
513+ isUpdatingExistingMachine bool
514+ want []gomegatypes.GomegaMatcher
515+ wantErr bool
518516 }{
519517 {
520518 name : "should return the correct Machine object when creating a new Machine" ,
@@ -555,8 +553,7 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
555553 HavePrefix (kcpName + namingTemplateKey ),
556554 Not (HaveSuffix ("00000" )),
557555 },
558- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" certificatesDir\" :\" foo\" }" ,
559- wantErr : false ,
556+ wantErr : false ,
560557 },
561558 {
562559 name : "should return error when creating a new Machine when '.random' is not added in template" ,
@@ -624,8 +621,7 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
624621 ContainSubstring (fmt .Sprintf ("%053d" , 0 )),
625622 Not (HaveSuffix ("00000" )),
626623 },
627- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" certificatesDir\" :\" foo\" }" ,
628- wantErr : false ,
624+ wantErr : false ,
629625 },
630626 {
631627 name : "should return error when creating a new Machine with invalid template" ,
@@ -691,7 +687,6 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
691687 HavePrefix (kcpName ),
692688 Not (HaveSuffix ("00000" )),
693689 },
694- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" certificatesDir\" :\" foo\" }" ,
695690 },
696691 {
697692 name : "should return the correct Machine object when creating a new Machine with additional kcp readinessGates" ,
@@ -724,9 +719,8 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
724719 },
725720 },
726721 },
727- isUpdatingExistingMachine : false ,
728- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" certificatesDir\" :\" foo\" }" ,
729- wantErr : false ,
722+ isUpdatingExistingMachine : false ,
723+ wantErr : false ,
730724 },
731725 {
732726 name : "should return the correct Machine object when updating an existing Machine (empty ClusterConfiguration annotation)" ,
@@ -762,10 +756,8 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
762756 },
763757 },
764758 },
765- isUpdatingExistingMachine : true ,
766- existingClusterConfigurationAnnotation : "" ,
767- wantClusterConfigurationAnnotation : "" ,
768- wantErr : false ,
759+ isUpdatingExistingMachine : true ,
760+ wantErr : false ,
769761 },
770762 {
771763 name : "should return the correct Machine object when updating an existing Machine (outdated ClusterConfiguration annotation)" ,
@@ -802,10 +794,7 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
802794 },
803795 },
804796 isUpdatingExistingMachine : true ,
805-
806- existingClusterConfigurationAnnotation : "{\" etcd\" :{},\" apiServer\" :{\" extraArgs\" :{\" foo\" :\" bar\" }},\" certificatesDir\" :\" foo\" }" ,
807- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" apiServer\" :{\" extraArgs\" :[{\" name\" :\" foo\" ,\" value\" :\" bar\" }]},\" certificatesDir\" :\" foo\" }" ,
808- wantErr : false ,
797+ wantErr : false ,
809798 },
810799 {
811800 name : "should return the correct Machine object when updating an existing Machine (up to date ClusterConfiguration annotation)" ,
@@ -841,10 +830,8 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
841830 },
842831 },
843832 },
844- isUpdatingExistingMachine : true ,
845- existingClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" etcd\" :{},\" apiServer\" :{\" extraArgs\" :[{\" name\" :\" foo\" ,\" value\" :\" bar\" }]},\" controllerManager\" :{},\" scheduler\" :{},\" dns\" :{},\" certificatesDir\" :\" foo\" }" ,
846- wantClusterConfigurationAnnotation : "{\" marshalVersion\" :\" v1beta2\" ,\" etcd\" :{},\" apiServer\" :{\" extraArgs\" :[{\" name\" :\" foo\" ,\" value\" :\" bar\" }]},\" controllerManager\" :{},\" scheduler\" :{},\" dns\" :{},\" certificatesDir\" :\" foo\" }" ,
847- wantErr : false ,
833+ isUpdatingExistingMachine : true ,
834+ wantErr : false ,
848835 },
849836 }
850837
@@ -887,9 +874,6 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
887874 ReadinessGates : []clusterv1.MachineReadinessGate {{ConditionType : "Foo" }},
888875 },
889876 }
890- if tt .existingClusterConfigurationAnnotation != "" {
891- existingMachine .Annotations [controlplanev1 .KubeadmClusterConfigurationAnnotation ] = tt .existingClusterConfigurationAnnotation
892- }
893877
894878 desiredMachine , err = (& KubeadmControlPlaneReconciler {}).computeDesiredMachine (
895879 tt .kcp , cluster ,
@@ -924,9 +908,6 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
924908 for k , v := range kcpMachineTemplateObjectMeta .Annotations {
925909 expectedAnnotations [k ] = v
926910 }
927- if tt .wantClusterConfigurationAnnotation != "" {
928- expectedAnnotations [controlplanev1 .KubeadmClusterConfigurationAnnotation ] = tt .wantClusterConfigurationAnnotation
929- }
930911 expectedAnnotations [controlplanev1 .RemediationForAnnotation ] = remediationData
931912 // The pre-terminate annotation should always be added
932913 expectedAnnotations [controlplanev1 .PreTerminateHookCleanupAnnotation ] = ""
@@ -962,7 +943,6 @@ func TestKubeadmControlPlaneReconciler_computeDesiredMachine(t *testing.T) {
962943 for k , v := range kcpMachineTemplateObjectMeta .Annotations {
963944 expectedAnnotations [k ] = v
964945 }
965- expectedAnnotations [controlplanev1 .KubeadmClusterConfigurationAnnotation ] = tt .wantClusterConfigurationAnnotation
966946 // The pre-terminate annotation should always be added
967947 expectedAnnotations [controlplanev1 .PreTerminateHookCleanupAnnotation ] = ""
968948 g .Expect (desiredMachine .Annotations ).To (Equal (expectedAnnotations ))
0 commit comments