Skip to content

Commit 4e170ca

Browse files
committed
Merge branch 'master' into agent-config-environment-uuid
2 parents a8ed424 + 9646af8 commit 4e170ca

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

upgrades/operations.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,17 @@ func newOpsIterator(from, to version.Number, ops []Operation) *opsIterator {
7676
if from == version.Zero {
7777
from = version.MustParse("1.16.0")
7878
}
79+
7980
// Clear the version tag of the target release to ensure that all
80-
// upgrade steps for the release are run for alpha and beta releases.
81-
to.Tag = ""
81+
// upgrade steps for the release are run for alpha and beta
82+
// releases.
83+
// ...but only do this if the agent version has actually changed,
84+
// lest we trigger upgrade mode unnecessarily for non-final
85+
// versions.
86+
if from.Compare(to) != 0 {
87+
to.Tag = ""
88+
}
89+
8290
return &opsIterator{
8391
from: from,
8492
to: to,

upgrades/upgrade_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,18 @@ var areUpgradesDefinedTests = []areUpgradesDefinedTest{
330330
fromVersion: "",
331331
expected: true,
332332
},
333+
{
334+
about: "upgrade between pre-final versions",
335+
fromVersion: "1.21-beta4",
336+
toVersion: "1.21-beta5",
337+
expected: true,
338+
},
339+
{
340+
about: "no upgrades when version hasn't changed, even with release tags",
341+
fromVersion: "1.21-beta5",
342+
toVersion: "1.21-beta5",
343+
expected: false,
344+
},
333345
}
334346

335347
func (s *upgradeSuite) TestAreUpgradesDefined(c *gc.C) {
@@ -500,6 +512,20 @@ var upgradeTests = []upgradeTest{
500512
targets: targets(upgrades.HostMachine),
501513
expectedSteps: []string{"step 1 - 1.20.0", "step 2 - 1.20.0", "step 1 - 1.21.0"},
502514
},
515+
{
516+
about: "nothing happens when the version hasn't changed but contains a tag",
517+
fromVersion: "1.21-alpha1",
518+
toVersion: "1.21-alpha1",
519+
targets: targets(upgrades.DatabaseMaster),
520+
expectedSteps: []string{},
521+
},
522+
{
523+
about: "upgrades between pre-final versions should run steps for the final version",
524+
fromVersion: "1.21-beta2",
525+
toVersion: "1.21-beta3",
526+
targets: targets(upgrades.DatabaseMaster),
527+
expectedSteps: []string{"state step 1 - 1.21.0", "step 1 - 1.21.0"},
528+
},
503529
}
504530

505531
func (s *upgradeSuite) TestPerformUpgrade(c *gc.C) {

0 commit comments

Comments
 (0)