Skip to content

Commit

Permalink
Skip service packs in upgrade path detection (vertica#176)
Browse files Browse the repository at this point in the history
The upgrade path detection that was added in v1.3.0 of the operator was too
strict when it came to checking for service packs. As per the Vertica docs,
those can be skipped when doing upgrades. This PR fixes that bug.
  • Loading branch information
spilchen committed Mar 21, 2022
1 parent e4be224 commit 2c1e9cc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions changes/unreleased/Fixed-20220315-110324.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: Fixed
body: Upgrade path detection should allow skipping service packs
time: 2022-03-15T11:03:24.512411223-03:00
custom:
Issue: "176"
24 changes: 18 additions & 6 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const (
// each release, the next release that must be upgrade too. Use this map to
// know if a new version is the next supported version by Vertica.
var UpgradePaths = map[Components]Info{
{11, 0, 0}: {"v11.0.1", Components{11, 0, 1}},
{11, 0, 1}: {"v11.0.2", Components{11, 0, 2}},
{11, 0, 2}: {"v11.1.0", Components{11, 1, 0}},
{11, 0, 0}: {"v11.1.x", Components{11, 1, 0}},
{11, 0, 1}: {"v11.1.x", Components{11, 1, 0}},
{11, 0, 2}: {"v11.1.x", Components{11, 1, 0}},
}

// MakeInfoFromVdb will construct an Info struct by extracting the version from the
Expand Down Expand Up @@ -112,7 +112,13 @@ func (i *Info) IsEqualOrNewer(inVer string) bool {

// IsEqual compares two versions to see if they are equal
func (i *Info) IsEqual(other *Info) bool {
return other.VdbMajor == i.VdbMajor && other.VdbMinor == i.VdbMinor && other.VdbPatch == i.VdbPatch
return i.IsEqualExceptPatch(other) && other.VdbPatch == i.VdbPatch
}

// IsEqualExceptPatch compares two versions major/minor versions to see if they
// are equal
func (i *Info) IsEqualExceptPatch(other *Info) bool {
return other.VdbMajor == i.VdbMajor && other.VdbMinor == i.VdbMinor
}

// IsValidUpgradePath will return true if the current version is allowed to
Expand All @@ -134,16 +140,22 @@ func (i *Info) IsValidUpgradePath(targetVer string) (ok bool, failureReason stri
fmt.Sprintf("Version '%s' to '%s' is a downgrade and is not supported",
i.VdbVer, t.VdbVer)
}
// Check if the major/minor versions are identical. It is okay to skip
// patch versions.
if i.IsEqualExceptPatch(t) {
return true, ""
}

// Check if the upgrade path is followed. You can only go from one released
// version to the next released version.
// version to the next released version, but patches are allowed to be skipped.
nextVer, ok := UpgradePaths[i.Components]
if !ok {
// The version isn't found in the upgrade path. This path may be
// unsafe, but we aren't going to block this incase we are using a
// version vertica that came out after the version of this operator.
return true, ""
}
if t.IsEqual(&nextVer) {
if t.IsEqualExceptPatch(&nextVer) {
return true, ""
}
return false,
Expand Down
4 changes: 3 additions & 1 deletion pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ var _ = Describe("version", func() {
ok, _ = cur.IsValidUpgradePath("v10.1.1")
Expect(ok).Should(BeFalse())
ok, _ = cur.IsValidUpgradePath("v11.1.0")
Expect(ok).Should(BeFalse()) // We fail because we skip v11.0.2
Expect(ok).Should(BeTrue())
ok, _ = cur.IsValidUpgradePath("v11.0.2")
Expect(ok).Should(BeTrue())
ok, _ = cur.IsValidUpgradePath("v11.2.2")
Expect(ok).Should(BeFalse()) // Fail because it skips v11.1.x

cur, ok = MakeInfoFromStr("v15.1.1")
Expect(ok).Should(BeTrue())
Expand Down

0 comments on commit 2c1e9cc

Please sign in to comment.