Skip to content

Commit dc4d39f

Browse files
DarrylWongsrosenberg
authored andcommitted
mixedversion: check minBootstrapVersion when deciding to skip versions
Previously the minBootstrapVersion check was done after the predecessors were picked. However, this ignored the special case where if it was the first time a skip upgrade was happening, it would force the plan to take the skip. This meant that if the skip upgrade was forced but was older than the minBootstrapVersion, the framework would reject it and we would get an invalid plan. This change moves the minBootstrapVersion check into the logic where we decide if we want to skip versions or not.
1 parent 9bee340 commit dc4d39f

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

pkg/cmd/roachtest/roachtestutil/mixedversion/mixedversion.go

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,15 +1026,21 @@ func (t *Test) runCommandFunc(nodes option.NodeListOption, cmd string) stepFunc
10261026
// ARM64 builds are only available on v22.2.0+.
10271027
func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
10281028
skipVersions := t.prng.Float64() < t.options.skipVersionProbability
1029+
numUpgrades := t.numUpgrades()
1030+
currentVersion := clusterupgrade.CurrentVersion()
1031+
10291032
isAvailable := func(v *clusterupgrade.Version) bool {
10301033
if t.clusterArch() != vm.ArchARM64 {
10311034
return true
10321035
}
10331036

10341037
return v.AtLeast(minSupportedARM64Version)
10351038
}
1039+
isOlderThanMinimumBootstrapVersion := func(v *clusterupgrade.Version) bool {
1040+
return t.options.minimumBootstrapVersion != nil && v.LessThan(t.options.minimumBootstrapVersion)
1041+
}
10361042

1037-
var numSkips int
1043+
forceSkipVersion := true
10381044
// possiblePredecessorsFor returns a list of possible predecessors
10391045
// for the given release `v`. If skip-version is enabled and
10401046
// supported, this function will return both the immediate
@@ -1047,6 +1053,12 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
10471053
return nil, err
10481054
}
10491055

1056+
// If the predecessor is older than the minimum bootstrap version,
1057+
// then it is not a legal predecessor.
1058+
if isOlderThanMinimumBootstrapVersion(pred) {
1059+
return nil, nil
1060+
}
1061+
10501062
if !isAvailable(pred) {
10511063
return nil, nil
10521064
}
@@ -1062,12 +1074,18 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
10621074
return nil, err
10631075
}
10641076

1077+
// If the skip upgrade predecessor is older than the minimum bootstrap version,
1078+
// then it is not a legal predecessor.
1079+
if isOlderThanMinimumBootstrapVersion(predPred) {
1080+
return []*clusterupgrade.Version{pred}, nil
1081+
}
1082+
10651083
// If we haven't performed a skip-version upgrade yet, do it. This logic
10661084
// makes sure that, when skip-version upgrades are enabled, it happens
10671085
// when upgrading to the current release, which is the most important
10681086
// upgrade to be tested on any release branch.
1069-
if numSkips == 0 {
1070-
numSkips++
1087+
if forceSkipVersion {
1088+
forceSkipVersion = false
10711089
return []*clusterupgrade.Version{predPred}, nil
10721090
}
10731091

@@ -1078,7 +1096,7 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
10781096

10791097
// possibleUpgradePathsMap maps a version to the possible upgrade paths that
10801098
// can be taken with exactly n upgrades.
1081-
possibleUpgradePathsMap := make(map[*clusterupgrade.Version]map[int][][]*clusterupgrade.Version)
1099+
possibleUpgradePathsMap := make(map[string]map[int][][]*clusterupgrade.Version)
10821100
// findPossibleUpgradePaths finds all legal upgrade paths ending at version `v` with
10831101
// exactly `numUpgrades` upgrades.
10841102
var findPossibleUpgradePaths func(v *clusterupgrade.Version, numUpgrades int) ([][]*clusterupgrade.Version, error)
@@ -1088,9 +1106,9 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
10881106
return [][]*clusterupgrade.Version{{v}}, nil
10891107
}
10901108
// Check if we have already computed the possible upgrade paths for this version.
1091-
if _, ok := possibleUpgradePathsMap[v]; !ok {
1092-
possibleUpgradePathsMap[v] = make(map[int][][]*clusterupgrade.Version)
1093-
} else if paths, ok := possibleUpgradePathsMap[v][numUpgrades]; ok {
1109+
if _, ok := possibleUpgradePathsMap[v.String()]; !ok {
1110+
possibleUpgradePathsMap[v.String()] = make(map[int][][]*clusterupgrade.Version)
1111+
} else if paths, ok := possibleUpgradePathsMap[v.String()][numUpgrades]; ok {
10941112
return paths, nil
10951113
}
10961114

@@ -1103,11 +1121,6 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
11031121
return nil, err
11041122
}
11051123
for _, pred := range predecessors {
1106-
// If the predecessor is older than the minimum bootstrapped version, then
1107-
// it's not a legal upgrade path.
1108-
if t.options.minimumBootstrapVersion != nil && pred.LessThan(t.options.minimumBootstrapVersion) {
1109-
continue
1110-
}
11111124
predPaths, err := findPossibleUpgradePaths(pred, numUpgrades-1)
11121125
if err != nil {
11131126
return nil, err
@@ -1117,13 +1130,11 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
11171130
}
11181131
}
11191132

1120-
possibleUpgradePathsMap[v][numUpgrades] = paths
1133+
possibleUpgradePathsMap[v.String()][numUpgrades] = paths
11211134
return paths, nil
11221135
}
11231136

1124-
currentVersion := clusterupgrade.CurrentVersion()
11251137
var upgradePath []*clusterupgrade.Version
1126-
numUpgrades := t.numUpgrades()
11271138

11281139
// Best effort to find a valid upgrade path with exactly numUpgrades. If one is
11291140
// not found because some release is not available for the cluster architecture,
@@ -1141,13 +1152,21 @@ func (t *Test) chooseUpgradePath() ([]*clusterupgrade.Version, error) {
11411152
upgradePath = possibleUpgradePaths[t.prng.Intn(len(possibleUpgradePaths))]
11421153
break
11431154
}
1155+
forceSkipVersion = true
11441156
}
11451157

1146-
if len(upgradePath) < numUpgrades {
1147-
if t.clusterArch() != vm.ArchARM64 {
1158+
if len(upgradePath) < (numUpgrades + 1) {
1159+
warnMsg := "WARNING: %d upgrades requested but found plan with only %d upgrades"
1160+
if skipVersions {
1161+
t.logger.Printf("%s: prioritizing running at least one skip version upgrade", warnMsg)
1162+
} else if t.clusterArch() == vm.ArchARM64 {
1163+
t.logger.Printf("%s: ARM64 is only supported on %s+", warnMsg, minSupportedARM64Version)
1164+
} else {
11481165
return nil, errors.Newf("unable to find a valid upgrade path with %d upgrades", numUpgrades)
11491166
}
1150-
t.logger.Printf("WARNING: skipping upgrades as ARM64 is only supported on %s+", minSupportedARM64Version)
1167+
}
1168+
if skipVersions && forceSkipVersion {
1169+
t.logger.Printf("WARNING: skip version upgrades were enabled but were not performed because the minimum supported or bootstrap version did not allow")
11511170
}
11521171
return upgradePath, nil
11531172
}

0 commit comments

Comments
 (0)