Skip to content

Commit 2f4c5c6

Browse files
committed
Avoid KCP rollouts if only timeouts are changed
1 parent 22fe91a commit 2f4c5c6

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

controlplane/kubeadm/internal/filters.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,14 @@ func PrepareKubeadmConfigsForDiff(desiredKubeadmConfig, currentKubeadmConfig *bo
341341
desiredKubeadmConfig.Spec.JoinConfiguration.Discovery = bootstrapv1.Discovery{}
342342
currentKubeadmConfig.Spec.JoinConfiguration.Discovery = bootstrapv1.Discovery{}
343343

344+
// Cleanup Timeouts from desiredKubeadmConfig and currentKubeadmConfig, because those info are relevant only for
345+
// the join process and not for comparing the configuration of the machine.
346+
// Note: Changes to Timeouts will apply for the next join, but they will not lead to a rollout.
347+
desiredKubeadmConfig.Spec.JoinConfiguration.Timeouts = bootstrapv1.Timeouts{}
348+
currentKubeadmConfig.Spec.JoinConfiguration.Timeouts = bootstrapv1.Timeouts{}
349+
desiredKubeadmConfig.Spec.InitConfiguration.Timeouts = bootstrapv1.Timeouts{}
350+
currentKubeadmConfig.Spec.InitConfiguration.Timeouts = bootstrapv1.Timeouts{}
351+
344352
// If KCP JoinConfiguration.ControlPlane is nil and the Machine JoinConfiguration.ControlPlane is empty,
345353
// set Machine JoinConfiguration.ControlPlane to nil.
346354
// NOTE: This is required because CABPK applies an empty JoinConfiguration.ControlPlane in case it is nil.

controlplane/kubeadm/internal/filters_test.go

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,13 @@ func TestMatchesKubeadmConfig(t *testing.T) {
338338
KubeadmConfigSpec: bootstrapv1.KubeadmConfigSpec{
339339
ClusterConfiguration: bootstrapv1.ClusterConfiguration{},
340340
JoinConfiguration: bootstrapv1.JoinConfiguration{
341-
Timeouts: bootstrapv1.Timeouts{
342-
ControlPlaneComponentHealthCheckSeconds: ptr.To[int32](5),
343-
KubernetesAPICallSeconds: ptr.To[int32](7),
341+
Timeouts: bootstrapv1.Timeouts{ // Timeouts are different, but they are ignored for the diff
342+
ControlPlaneComponentHealthCheckSeconds: ptr.To[int32](1),
343+
KubeletHealthCheckSeconds: ptr.To[int32](2),
344+
KubernetesAPICallSeconds: ptr.To[int32](3),
345+
EtcdAPICallSeconds: ptr.To[int32](4),
346+
TLSBootstrapSeconds: ptr.To[int32](5),
347+
DiscoverySeconds: ptr.To[int32](6),
344348
},
345349
Patches: bootstrapv1.Patches{
346350
Directory: "/test/patches",
@@ -391,9 +395,13 @@ func TestMatchesKubeadmConfig(t *testing.T) {
391395
Spec: bootstrapv1.KubeadmConfigSpec{
392396
// InitConfiguration will be converted to JoinConfiguration and then compared against the JoinConfiguration from KCP.
393397
InitConfiguration: bootstrapv1.InitConfiguration{
394-
Timeouts: bootstrapv1.Timeouts{
395-
ControlPlaneComponentHealthCheckSeconds: ptr.To[int32](5),
396-
KubernetesAPICallSeconds: ptr.To[int32](7),
398+
Timeouts: bootstrapv1.Timeouts{ // Timeouts are different, but they are ignored for the diff
399+
ControlPlaneComponentHealthCheckSeconds: ptr.To[int32](11),
400+
KubeletHealthCheckSeconds: ptr.To[int32](12),
401+
KubernetesAPICallSeconds: ptr.To[int32](13),
402+
EtcdAPICallSeconds: ptr.To[int32](14),
403+
TLSBootstrapSeconds: ptr.To[int32](15),
404+
DiscoverySeconds: ptr.To[int32](16),
397405
},
398406
Patches: bootstrapv1.Patches{
399407
Directory: "/test/patches",
@@ -612,7 +620,7 @@ func TestMatchesKubeadmConfig(t *testing.T) {
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,14 @@ 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+
KubeletHealthCheckSeconds: ptr.To[int32](2),
639+
KubernetesAPICallSeconds: ptr.To[int32](3),
640+
EtcdAPICallSeconds: ptr.To[int32](4),
641+
TLSBootstrapSeconds: ptr.To[int32](5),
642+
DiscoverySeconds: ptr.To[int32](6),
643+
},
628644
},
629645
},
630646
Version: "v1.30.0",
@@ -658,6 +674,14 @@ func TestMatchesKubeadmConfig(t *testing.T) {
658674
},
659675
// Discovery gets removed because Discovery is not relevant for the rollout decision.
660676
Discovery: bootstrapv1.Discovery{TLSBootstrapToken: "bbb"},
677+
Timeouts: bootstrapv1.Timeouts{
678+
ControlPlaneComponentHealthCheckSeconds: ptr.To[int32](11),
679+
KubeletHealthCheckSeconds: ptr.To[int32](12),
680+
KubernetesAPICallSeconds: ptr.To[int32](13),
681+
EtcdAPICallSeconds: ptr.To[int32](14),
682+
TLSBootstrapSeconds: ptr.To[int32](15),
683+
DiscoverySeconds: ptr.To[int32](16),
684+
},
661685
},
662686
},
663687
},

0 commit comments

Comments
 (0)