Skip to content

Commit

Permalink
Merge pull request #11325 from k8s-infra-cherrypick-robot/cherry-pick…
Browse files Browse the repository at this point in the history
…-11319-to-release-1.8

[release-1.8] 🌱 KCP: Skip validation if CoreDNS migration library supports an upgrade if the library is not used
  • Loading branch information
k8s-ci-robot authored Oct 22, 2024
2 parents 180f8f3 + 25334cf commit c5c03c6
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 c5c03c6

Please sign in to comment.