@@ -339,6 +339,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
339339 ClusterConfiguration : bootstrapv1.ClusterConfiguration {},
340340 JoinConfiguration : bootstrapv1.JoinConfiguration {
341341 Timeouts : bootstrapv1.Timeouts {
342+ // ControlPlaneComponentHealthCheckSeconds is different, but it is ignored for the diff
342343 ControlPlaneComponentHealthCheckSeconds : ptr.To [int32 ](5 ),
343344 KubernetesAPICallSeconds : ptr.To [int32 ](7 ),
344345 },
@@ -392,7 +393,8 @@ func TestMatchesKubeadmConfig(t *testing.T) {
392393 // InitConfiguration will be converted to JoinConfiguration and then compared against the JoinConfiguration from KCP.
393394 InitConfiguration : bootstrapv1.InitConfiguration {
394395 Timeouts : bootstrapv1.Timeouts {
395- ControlPlaneComponentHealthCheckSeconds : ptr.To [int32 ](5 ),
396+ // ControlPlaneComponentHealthCheckSeconds is different, but it is ignored for the diff
397+ ControlPlaneComponentHealthCheckSeconds : ptr.To [int32 ](1 ),
396398 KubernetesAPICallSeconds : ptr.To [int32 ](7 ),
397399 },
398400 Patches : bootstrapv1.Patches {
@@ -420,7 +422,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
420422 g .Expect (err ).ToNot (HaveOccurred ())
421423 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
422424 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
423- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
425+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
424426 g .Expect (match ).To (BeTrue ())
425427 g .Expect (reason ).To (BeEmpty ())
426428 })
@@ -478,7 +480,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
478480 g .Expect (err ).ToNot (HaveOccurred ())
479481 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
480482 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
481- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
483+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
482484 g .Expect (match ).To (BeTrue ())
483485 g .Expect (reason ).To (BeEmpty ())
484486 })
@@ -536,7 +538,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
536538 g .Expect (err ).ToNot (HaveOccurred ())
537539 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
538540 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
539- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
541+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
540542 g .Expect (match ).To (BeFalse ())
541543 g .Expect (reason ).To (BeComparableTo (`Machine KubeadmConfig is outdated: diff: &v1beta2.KubeadmConfigSpec{
542544 ClusterConfiguration: {},
@@ -597,6 +599,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
597599 },
598600 Spec : bootstrapv1.KubeadmConfigSpec {
599601 JoinConfiguration : bootstrapv1.JoinConfiguration {
602+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
603+ Discovery : bootstrapv1.Discovery {
604+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
605+ APIServerEndpoint : "1.2.3.4:6443" ,
606+ },
607+ },
600608 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
601609 Name : "A new name" ,
602610 },
@@ -608,11 +616,11 @@ func TestMatchesKubeadmConfig(t *testing.T) {
608616 g .Expect (err ).ToNot (HaveOccurred ())
609617 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
610618 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
611- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
619+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
612620 g .Expect (match ).To (BeTrue ())
613621 g .Expect (reason ).To (BeEmpty ())
614622 })
615- t .Run ("returns true if JoinConfiguration is equal apart from discovery " , func (t * testing.T ) {
623+ t .Run ("returns true if JoinConfiguration is equal apart from Discovery and Timeouts " , func (t * testing.T ) {
616624 g := NewWithT (t )
617625 kcp := & controlplanev1.KubeadmControlPlane {
618626 Spec : controlplanev1.KubeadmControlPlaneSpec {
@@ -625,6 +633,9 @@ func TestMatchesKubeadmConfig(t *testing.T) {
625633 },
626634 // Discovery gets removed because Discovery is not relevant for the rollout decision.
627635 Discovery : bootstrapv1.Discovery {TLSBootstrapToken : "aaa" },
636+ Timeouts : bootstrapv1.Timeouts {
637+ ControlPlaneComponentHealthCheckSeconds : ptr.To [int32 ](1 ),
638+ },
628639 },
629640 },
630641 Version : "v1.30.0" ,
@@ -656,8 +667,16 @@ func TestMatchesKubeadmConfig(t *testing.T) {
656667 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
657668 Name : "A new name" ,
658669 },
659- // Discovery gets removed because Discovery is not relevant for the rollout decision.
660- Discovery : bootstrapv1.Discovery {TLSBootstrapToken : "bbb" },
670+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
671+ // Discovery gets removed only for the diff because Discovery is not relevant for the rollout decision.
672+ Discovery : bootstrapv1.Discovery {
673+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
674+ APIServerEndpoint : "1.2.3.4:6443" ,
675+ },
676+ },
677+ Timeouts : bootstrapv1.Timeouts {
678+ ControlPlaneComponentHealthCheckSeconds : ptr.To [int32 ](11 ),
679+ },
661680 },
662681 },
663682 },
@@ -666,7 +685,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
666685 g .Expect (err ).ToNot (HaveOccurred ())
667686 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
668687 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
669- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
688+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
670689 g .Expect (match ).To (BeTrue ())
671690 g .Expect (reason ).To (BeEmpty ())
672691 })
@@ -710,6 +729,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
710729 },
711730 Spec : bootstrapv1.KubeadmConfigSpec {
712731 JoinConfiguration : bootstrapv1.JoinConfiguration {
732+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
733+ Discovery : bootstrapv1.Discovery {
734+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
735+ APIServerEndpoint : "1.2.3.4:6443" ,
736+ },
737+ },
713738 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
714739 Name : "A new name" ,
715740 },
@@ -722,7 +747,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
722747 g .Expect (err ).ToNot (HaveOccurred ())
723748 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
724749 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
725- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
750+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
726751 g .Expect (match ).To (BeTrue ())
727752 g .Expect (reason ).To (BeEmpty ())
728753 })
@@ -780,7 +805,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
780805 g .Expect (err ).ToNot (HaveOccurred ())
781806 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
782807 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
783- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
808+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
784809 g .Expect (match ).To (BeFalse ())
785810 g .Expect (reason ).To (Equal (`Machine KubeadmConfig is outdated: diff: &v1beta2.KubeadmConfigSpec{
786811 ClusterConfiguration: {},
@@ -842,6 +867,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
842867 },
843868 Spec : bootstrapv1.KubeadmConfigSpec {
844869 JoinConfiguration : bootstrapv1.JoinConfiguration {
870+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
871+ Discovery : bootstrapv1.Discovery {
872+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
873+ APIServerEndpoint : "1.2.3.4:6443" ,
874+ },
875+ },
845876 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
846877 Name : "name" ,
847878 },
@@ -859,7 +890,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
859890 g .Expect (err ).ToNot (HaveOccurred ())
860891 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
861892 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
862- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
893+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
863894 g .Expect (match ).To (BeFalse ())
864895 g .Expect (reason ).To (Equal (`Machine KubeadmConfig is outdated: diff: &v1beta2.KubeadmConfigSpec{
865896 ClusterConfiguration: {},
@@ -920,6 +951,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
920951 },
921952 Spec : bootstrapv1.KubeadmConfigSpec {
922953 JoinConfiguration : bootstrapv1.JoinConfiguration {
954+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
955+ Discovery : bootstrapv1.Discovery {
956+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
957+ APIServerEndpoint : "1.2.3.4:6443" ,
958+ },
959+ },
923960 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
924961 Name : "An old name" , // This is a change
925962 },
@@ -931,7 +968,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
931968 g .Expect (err ).ToNot (HaveOccurred ())
932969 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
933970 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
934- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
971+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
935972 g .Expect (match ).To (BeFalse ())
936973 g .Expect (reason ).To (BeComparableTo (`Machine KubeadmConfig is outdated: diff: &v1beta2.KubeadmConfigSpec{
937974 ClusterConfiguration: {},
@@ -988,6 +1025,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
9881025 },
9891026 Spec : bootstrapv1.KubeadmConfigSpec {
9901027 JoinConfiguration : bootstrapv1.JoinConfiguration {
1028+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
1029+ Discovery : bootstrapv1.Discovery {
1030+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
1031+ APIServerEndpoint : "1.2.3.4:6443" ,
1032+ },
1033+ },
9911034 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
9921035 Name : "An old name" , // This is a change
9931036 },
@@ -1071,6 +1114,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
10711114 ClusterConfiguration : bootstrapv1.ClusterConfiguration {},
10721115 InitConfiguration : bootstrapv1.InitConfiguration {},
10731116 JoinConfiguration : bootstrapv1.JoinConfiguration {
1117+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
1118+ Discovery : bootstrapv1.Discovery {
1119+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
1120+ APIServerEndpoint : "1.2.3.4:6443" ,
1121+ },
1122+ },
10741123 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
10751124 Name : "name" ,
10761125 },
@@ -1082,7 +1131,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
10821131 g .Expect (err ).ToNot (HaveOccurred ())
10831132 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
10841133 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
1085- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
1134+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
10861135 g .Expect (match ).To (BeTrue ())
10871136 g .Expect (reason ).To (BeEmpty ())
10881137 })
@@ -1125,6 +1174,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
11251174 Spec : bootstrapv1.KubeadmConfigSpec {
11261175 Format : "" ,
11271176 JoinConfiguration : bootstrapv1.JoinConfiguration {
1177+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
1178+ Discovery : bootstrapv1.Discovery {
1179+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
1180+ APIServerEndpoint : "1.2.3.4:6443" ,
1181+ },
1182+ },
11281183 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
11291184 Name : "name" ,
11301185 },
@@ -1136,7 +1191,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
11361191 g .Expect (err ).ToNot (HaveOccurred ())
11371192 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
11381193 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
1139- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
1194+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
11401195 g .Expect (match ).To (BeTrue ())
11411196 g .Expect (reason ).To (BeEmpty ())
11421197 })
@@ -1180,6 +1235,12 @@ func TestMatchesKubeadmConfig(t *testing.T) {
11801235 },
11811236 Spec : bootstrapv1.KubeadmConfigSpec {
11821237 JoinConfiguration : bootstrapv1.JoinConfiguration {
1238+ // This field is technically set by CABPK, but adding it here so that matchesKubeadmConfig detects this correctly as a join KubeadmConfig.
1239+ Discovery : bootstrapv1.Discovery {
1240+ BootstrapToken : bootstrapv1.BootstrapTokenDiscovery {
1241+ APIServerEndpoint : "1.2.3.4:6443" ,
1242+ },
1243+ },
11831244 NodeRegistration : bootstrapv1.NodeRegistrationOptions {
11841245 Name : "name" ,
11851246 },
@@ -1191,7 +1252,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
11911252 g .Expect (err ).ToNot (HaveOccurred ())
11921253 g .Expect (currentKubeadmConfig ).ToNot (BeNil ())
11931254 g .Expect (desiredKubeadmConfig ).ToNot (BeNil ())
1194- g .Expect (isKubeadmConfigForJoin ( desiredKubeadmConfig )) .To (BeTrue ())
1255+ g .Expect (desiredKubeadmConfig . Spec . InitConfiguration ) .To (Equal (bootstrapv1. InitConfiguration {})) // Verify that this is a join.
11951256 g .Expect (match ).To (BeFalse ())
11961257 g .Expect (reason ).To (BeComparableTo (`Machine KubeadmConfig is outdated: diff: &v1beta2.KubeadmConfigSpec{
11971258 ClusterConfiguration: {},
0 commit comments