Skip to content

Commit fa7d6e0

Browse files
authored
Merge pull request #11319 from sbueringer/pr-skip-kcp-val
🌱 KCP: Skip validation if CoreDNS migration library supports an upgrade if the library is not used
2 parents f584a9b + 7e13754 commit fa7d6e0

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

controlplane/kubeadm/internal/webhooks/kubeadm_control_plane.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,12 @@ func (webhook *KubeadmControlPlane) validateCoreDNSVersion(oldK, newK *controlpl
620620
if toVersion.Equals(fromVersion) {
621621
return allErrs
622622
}
623+
624+
// Skip validating if the skip CoreDNS annotation is set. If set, KCP doesn't use the migration library.
625+
if _, ok := newK.Annotations[controlplanev1.SkipCoreDNSAnnotation]; ok {
626+
return allErrs
627+
}
628+
623629
if err := migration.ValidUpMigration(fromVersion.String(), toVersion.String()); err != nil {
624630
allErrs = append(
625631
allErrs,

controlplane/kubeadm/internal/webhooks/kubeadm_control_plane_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,17 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
554554
},
555555
}
556556

557+
validUnsupportedCoreDNSVersionWithSkipAnnotation := dns.DeepCopy()
558+
validUnsupportedCoreDNSVersionWithSkipAnnotation.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
559+
ImageMeta: bootstrapv1.ImageMeta{
560+
ImageRepository: "gcr.io/capi-test",
561+
ImageTag: "v99.99.99",
562+
},
563+
}
564+
validUnsupportedCoreDNSVersionWithSkipAnnotation.Annotations = map[string]string{
565+
controlplanev1.SkipCoreDNSAnnotation: "",
566+
}
567+
557568
unsetCoreDNSToVersion := dns.DeepCopy()
558569
unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
559570
ImageMeta: bootstrapv1.ImageMeta{
@@ -860,6 +871,17 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
860871
before: validUnsupportedCoreDNSVersion,
861872
kcp: validUnsupportedCoreDNSVersion,
862873
},
874+
{
875+
name: "should fail when upgrading to an unsupported version",
876+
before: dns,
877+
kcp: validUnsupportedCoreDNSVersion,
878+
expectErr: true,
879+
},
880+
{
881+
name: "should succeed when upgrading to an unsupported version and KCP has skip annotation set",
882+
before: dns,
883+
kcp: validUnsupportedCoreDNSVersionWithSkipAnnotation,
884+
},
863885
{
864886
name: "should fail when using an invalid DNS build",
865887
expectErr: true,

0 commit comments

Comments
 (0)