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 25, 2022
1 parent 917ab31 commit cab94d2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ func (in *KubeadmControlPlane) validateCoreDNSVersion(prev *KubeadmControlPlane)
)
return allErrs
}

// Note: This check allows an "upgrade" in the case where the versions are equal.
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 @@ -744,6 +744,11 @@ 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 fail when using an invalid DNS build",
expectErr: true,
Expand All @@ -756,6 +761,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
7 changes: 3 additions & 4 deletions controlplane/kubeadm/internal/workload_cluster_coredns.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,9 @@ func validateCoreDNSImageTag(fromTag, toTag string) error {
if err != nil {
return errors.Wrapf(err, "failed to parse CoreDNS target version %q", toTag)
}
// make sure that the version we're upgrading to is greater than the current one,
// or if they're the same version, the raw tags should be different (e.g. allow from `v1.17.4-somevendor.0` to `v1.17.4-somevendor.1`).
if x := from.Compare(to); x > 0 || (x == 0 && fromTag == toTag) {
return fmt.Errorf("toVersion %q must be greater than fromVersion %q", toTag, fromTag)
// make sure that the version we're upgrading to is greater than or equal to the current version.
if to.LT(from) {
return fmt.Errorf("toVersion %q must be greater than or equal to fromVersion %q", toTag, fromTag)
}
// check if the from version is even in the list of coredns versions
if _, ok := migration.Versions[fmt.Sprintf("%d.%d.%d", from.Major, from.Minor, from.Patch)]; !ok {
Expand Down
11 changes: 5 additions & 6 deletions controlplane/kubeadm/internal/workload_cluster_coredns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,17 +491,16 @@ func TestValidateCoreDNSImageTag(t *testing.T) {
toVer: "1.6.1",
expectErrSubStr: "failed to parse CoreDNS current version",
},
{
name: "fromVer is equal to toVer",
fromVer: "1.6.5",
toVer: "1.6.5",
},
{
name: "fromVer is equal to toVer, but different patch versions",
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 cab94d2

Please sign in to comment.