Skip to content

Commit

Permalink
WIP: Bug 1822844: Block z level upgrades
Browse files Browse the repository at this point in the history
CVO Upgradeable=False should block all upgrades including z level.
  • Loading branch information
jottofar committed Apr 30, 2020
1 parent fa452c2 commit 27cea86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
14 changes: 14 additions & 0 deletions pkg/payload/precondition/clusterversion/upgradable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ func TestUpgradeableRun(t *testing.T) {
upgradeable: ptr(configv1.ConditionFalse),
currVersion: "4.1.3",
desiredVersion: "4.1.4",
expected: "set to False",
},
{
name: "move-z, with true condition",
upgradeable: ptr(configv1.ConditionTrue),
currVersion: "4.1.3",
desiredVersion: "4.1.4",
expected: "",
},
{
name: "move-z, with unknown condition",
upgradeable: ptr(configv1.ConditionUnknown),
currVersion: "4.1.3",
desiredVersion: "4.1.4",
expected: "",
},
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/payload/precondition/clusterversion/upgradeable.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ func (pf *Upgradeable) Run(ctx context.Context, releaseContext precondition.Rele
return nil
}

currentMinor := getEffectiveMinor(cv.Status.History[0].Version)
desiredMinor := getEffectiveMinor(releaseContext.DesiredVersion)
// only perform minor version check if upgradeable is not false
if up.Status != configv1.ConditionFalse {
currentMinor := getEffectiveMinor(cv.Status.History[0].Version)
desiredMinor := getEffectiveMinor(releaseContext.DesiredVersion)

// if there is no difference in the minor version (4.y.z where 4.y is the same for current and desired), then we can still upgrade
if currentMinor == desiredMinor {
klog.V(4).Infof("Precondition %q passed: minor from the current %s matches minor from the target %s (both %s).", pf.Name(), cv.Status.History[0].Version, releaseContext.DesiredVersion, currentMinor)
return nil
// if there is no difference in the minor version (4.y.z where 4.y is the same for current and desired), then we can still upgrade
if currentMinor == desiredMinor {
klog.V(4).Infof("Precondition %q passed: minor from the current %s matches minor from the target %s (both %s).", pf.Name(), cv.Status.History[0].Version, releaseContext.DesiredVersion, currentMinor)
return nil
}
}

return &precondition.Error{
Expand Down

0 comments on commit 27cea86

Please sign in to comment.