Skip to content

Commit 72ef359

Browse files
authored
Merge pull request #5986 from killianmuldoon/fix/kcp-coredns-check
🐛 Allow KCP to Update when CoreDNS version doesn't change
2 parents c4b4c29 + d57f0f6 commit 72ef359

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,11 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane)
500500
)
501501
return allErrs
502502
}
503-
503+
// If the versions are equal return here without error.
504+
// This allows an upgrade where the version of CoreDNS in use is not supported by the migration tool.
505+
if toVersion.Equals(fromVersion) {
506+
return allErrs
507+
}
504508
if err := migration.ValidUpMigration(fromVersion.String(), toVersion.String()); err != nil {
505509
allErrs = append(
506510
allErrs,

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
484484
ImageTag: "v1.6.6_foobar.2",
485485
},
486486
}
487+
validUnsupportedCoreDNSVersion := dns.DeepCopy()
488+
validUnsupportedCoreDNSVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
489+
ImageMeta: bootstrapv1.ImageMeta{
490+
ImageRepository: "gcr.io/capi-test",
491+
ImageTag: "v99.99.99",
492+
},
493+
}
487494

488495
unsetCoreDNSToVersion := dns.DeepCopy()
489496
unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
@@ -744,6 +751,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
744751
before: before,
745752
kcp: dnsBuildTag,
746753
},
754+
{
755+
name: "should succeed when using the same CoreDNS version",
756+
before: dns,
757+
kcp: dns.DeepCopy(),
758+
},
759+
{
760+
name: "should succeed when using the same CoreDNS version - not supported",
761+
before: validUnsupportedCoreDNSVersion,
762+
kcp: validUnsupportedCoreDNSVersion,
763+
},
747764
{
748765
name: "should fail when using an invalid DNS build",
749766
expectErr: true,
@@ -756,6 +773,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
756773
before: dns,
757774
kcp: dnsInvalidCoreDNSToVersion,
758775
},
776+
759777
{
760778
name: "should fail when making a change to the cluster config's certificatesDir",
761779
expectErr: true,

0 commit comments

Comments
 (0)