Skip to content

Commit

Permalink
Skip checking DNS filed when checking KCP MachineNeedRollout
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi080513 authored and k8s-infra-cherrypick-robot committed Mar 22, 2024
1 parent 5f20c32 commit e340ba4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controlplane/kubeadm/internal/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ func matchClusterConfiguration(kcp *controlplanev1.KubeadmControlPlane, machine
if machineClusterConfig == nil {
machineClusterConfig = &bootstrapv1.ClusterConfiguration{}
}
kcpLocalClusterConfiguration := kcp.Spec.KubeadmConfigSpec.ClusterConfiguration

kcpLocalClusterConfiguration := kcp.Spec.KubeadmConfigSpec.ClusterConfiguration.DeepCopy()
if kcpLocalClusterConfiguration == nil {
kcpLocalClusterConfiguration = &bootstrapv1.ClusterConfiguration{}
}

// Skip checking DNS fields because we can update the configuration of the working cluster in place.
kcpLocalClusterConfiguration.DNS = bootstrapv1.DNS{}
machineClusterConfig.DNS = bootstrapv1.DNS{}

// Compare and return.
return reflect.DeepEqual(machineClusterConfig, kcpLocalClusterConfiguration)
}
Expand Down
25 changes: 25 additions & 0 deletions controlplane/kubeadm/internal/filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,31 @@ func TestMatchClusterConfiguration(t *testing.T) {
}
g.Expect(matchClusterConfiguration(kcp, m)).To(BeTrue())
})
t.Run("Return true although the DNS fields are different", func(t *testing.T) {
g := NewWithT(t)
kcp := &controlplanev1.KubeadmControlPlane{
Spec: controlplanev1.KubeadmControlPlaneSpec{
KubeadmConfigSpec: bootstrapv1.KubeadmConfigSpec{
ClusterConfiguration: &bootstrapv1.ClusterConfiguration{
DNS: bootstrapv1.DNS{
ImageMeta: bootstrapv1.ImageMeta{
ImageTag: "v1.10.1",
ImageRepository: "gcr.io/capi-test",
},
},
},
},
},
}
m := &clusterv1.Machine{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
controlplanev1.KubeadmClusterConfigurationAnnotation: "{\"dns\":{\"imageRepository\":\"gcr.io/capi-test\",\"imageTag\":\"v1.9.3\"}}",
},
},
}
g.Expect(matchClusterConfiguration(kcp, m)).To(BeTrue())
})
}

func TestGetAdjustedKcpConfig(t *testing.T) {
Expand Down

0 comments on commit e340ba4

Please sign in to comment.