Skip to content

Commit a09a885

Browse files
authored
Merge pull request #6003 from killianmuldoon/fix/kcp-coredns-check-1.0
🐛 Allow KCP to Update when CoreDNS version doesn't change
2 parents bec2cd4 + 3dcbcc2 commit a09a885

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
@@ -475,7 +475,11 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane)
475475
)
476476
return allErrs
477477
}
478-
478+
// If the versions are equal return here without error.
479+
// This allows an upgrade where the version of CoreDNS in use is not supported by the migration tool.
480+
if toVersion.Equals(fromVersion) {
481+
return allErrs
482+
}
479483
if err := migration.ValidUpMigration(fromVersion.String(), toVersion.String()); err != nil {
480484
allErrs = append(
481485
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
@@ -447,6 +447,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
447447
ImageTag: "v1.6.6_foobar.2",
448448
},
449449
}
450+
validUnsupportedCoreDNSVersion := dns.DeepCopy()
451+
validUnsupportedCoreDNSVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
452+
ImageMeta: bootstrapv1.ImageMeta{
453+
ImageRepository: "gcr.io/capi-test",
454+
ImageTag: "v99.99.99",
455+
},
456+
}
450457

451458
unsetCoreDNSToVersion := dns.DeepCopy()
452459
unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
@@ -688,6 +695,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
688695
before: before,
689696
kcp: dnsBuildTag,
690697
},
698+
{
699+
name: "should succeed when using the same CoreDNS version",
700+
before: dns,
701+
kcp: dns.DeepCopy(),
702+
},
703+
{
704+
name: "should succeed when using the same CoreDNS version - not supported",
705+
before: validUnsupportedCoreDNSVersion,
706+
kcp: validUnsupportedCoreDNSVersion,
707+
},
691708
{
692709
name: "should fail when using an invalid DNS build",
693710
expectErr: true,
@@ -700,6 +717,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
700717
before: dns,
701718
kcp: dnsInvalidCoreDNSToVersion,
702719
},
720+
703721
{
704722
name: "should fail when making a change to the cluster config's certificatesDir",
705723
expectErr: true,

0 commit comments

Comments
 (0)