Skip to content

Commit

Permalink
KCP: Skip validation if CoreDNS migration library supports an upgrade…
Browse files Browse the repository at this point in the history
… if skip CoreDNS is set

Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer authored and k8s-infra-cherrypick-robot committed Oct 22, 2024
1 parent 180f8f3 commit 25334cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,12 @@ func (webhook *KubeadmControlPlane) validateCoreDNSVersion(oldK, newK *controlpl
if toVersion.Equals(fromVersion) {
return allErrs
}

// Skip validating if the skip CoreDNS annotation is set. If set, KCP doesn't use the migration library.
if _, ok := newK.Annotations[controlplanev1.SkipCoreDNSAnnotation]; ok {
return allErrs
}

if err := migration.ValidUpMigration(fromVersion.String(), toVersion.String()); err != nil {
allErrs = append(
allErrs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,17 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
},
}

validUnsupportedCoreDNSVersionWithSkipAnnotation := dns.DeepCopy()
validUnsupportedCoreDNSVersionWithSkipAnnotation.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
ImageMeta: bootstrapv1.ImageMeta{
ImageRepository: "gcr.io/capi-test",
ImageTag: "v99.99.99",
},
}
validUnsupportedCoreDNSVersionWithSkipAnnotation.Annotations = map[string]string{
controlplanev1.SkipCoreDNSAnnotation: "",
}

unsetCoreDNSToVersion := dns.DeepCopy()
unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
ImageMeta: bootstrapv1.ImageMeta{
Expand Down Expand Up @@ -860,6 +871,17 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: validUnsupportedCoreDNSVersion,
kcp: validUnsupportedCoreDNSVersion,
},
{
name: "should fail when upgrading to an unsupported version",
before: dns,
kcp: validUnsupportedCoreDNSVersion,
expectErr: true,
},
{
name: "should succeed when upgrading to an unsupported version and KCP has skip annotation set",
before: dns,
kcp: validUnsupportedCoreDNSVersionWithSkipAnnotation,
},
{
name: "should fail when using an invalid DNS build",
expectErr: true,
Expand Down

0 comments on commit 25334cf

Please sign in to comment.