Skip to content

Commit

Permalink
allow KCP to Update when CoreDNS version doesn't change
Browse files Browse the repository at this point in the history
Signed-off-by: killianmuldoon <[email protected]>
  • Loading branch information
killianmuldoon committed Jan 26, 2022
1 parent 5b9922a commit 7de85c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane)
)
return allErrs
}

// If the versions are equal return here without error.
// This allows an upgrades where the version of CoreDNS in use is not supported by the migration tool.
if toVersion.Equals(fromVersion) {
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 @@ -484,6 +484,13 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
ImageTag: "v1.6.6_foobar.2",
},
}
validUnsupportedCoreDNSVersion := dns.DeepCopy()
validUnsupportedCoreDNSVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
ImageMeta: bootstrapv1.ImageMeta{
ImageRepository: "gcr.io/capi-test",
ImageTag: "v99.99.99",
},
}

unsetCoreDNSToVersion := dns.DeepCopy()
unsetCoreDNSToVersion.Spec.KubeadmConfigSpec.ClusterConfiguration.DNS = bootstrapv1.DNS{
Expand Down Expand Up @@ -744,6 +751,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: before,
kcp: dnsBuildTag,
},
{
name: "should succeed when using the same CoreDNS version",
before: dns,
kcp: dns.DeepCopy(),
},
{
name: "should succeed when using the same CoreDNS version - not supported",
before: validUnsupportedCoreDNSVersion,
kcp: validUnsupportedCoreDNSVersion,
},
{
name: "should fail when using an invalid DNS build",
expectErr: true,
Expand All @@ -756,6 +773,7 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
before: dns,
kcp: dnsInvalidCoreDNSToVersion,
},

{
name: "should fail when making a change to the cluster config's certificatesDir",
expectErr: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,6 @@ func TestValidateCoreDNSImageTag(t *testing.T) {
fromVer: "1.6.5_foobar.1",
toVer: "1.6.5_foobar.2",
},
{
name: "fromVer is equal to toVer",
fromVer: "1.6.5_foobar.1",
toVer: "1.6.5_foobar.1",
expectErrSubStr: "must be greater",
},
{
name: "fromVer is lower but has meta",
fromVer: "1.6.5-foobar.1",
Expand Down

0 comments on commit 7de85c6

Please sign in to comment.