From bdeeb75973ed033120c3df4a08f6c6ace715b317 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 25 Jul 2023 15:06:50 +0200 Subject: [PATCH 1/4] fix: upgrade force logic parity with deploy force logic https://git.coopcloud.tech/coop-cloud/organising/issues/444#issue-3388 --- cli/app/upgrade.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 197a9ab6..85fd8e8c 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -145,6 +145,11 @@ recipes. } } + if internal.Force && chosenUpgrade == "" { + logrus.Warnf("%s is already upgraded to latest but continuing (--force/--chaos)", app.Name) + chosenUpgrade = deployedVersion + } + // if release notes written after git tag published, read them before we // check out the tag and then they'll appear to be missing. this covers // when we obviously will forget to write release notes before publishing -- 2.40.1 From 0582147874efe82e3609bc2786b3ea2d68a6a8ff Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 25 Jul 2023 15:07:29 +0200 Subject: [PATCH 2/4] fix: better error message for missing local tag Aiming to help the following scenario better: https://git.coopcloud.tech/coop-cloud/organising/issues/444#issuecomment-16351 --- pkg/recipe/recipe.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 0c63725c..14661215 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -317,7 +317,7 @@ func EnsureVersion(recipeName, version string) error { logrus.Debugf("read %s as tags for recipe %s", strings.Join(parsedTags, ", "), recipeName) if tagRef.String() == "" { - return fmt.Errorf("no published release discovered for %s", recipeName) + return fmt.Errorf("the local copy of %s doesn't seem to have version %s available?", recipeName, version) } worktree, err := repo.Worktree() -- 2.40.1 From 69f38ea445918711e95800af109e328d4ff3787d Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 25 Jul 2023 15:08:10 +0200 Subject: [PATCH 3/4] fix: always show overview, even with -f https://git.coopcloud.tech/coop-cloud/organising/issues/444 --- cli/app/rollback.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 5b986cbf..d3f7c61f 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -186,10 +186,8 @@ recipes. config.SetChaosVersionLabel(compose, stackName, chosenDowngrade) config.SetUpdateLabel(compose, stackName, app.Env) - if !internal.Force { - if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { - logrus.Fatal(err) - } + if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { + logrus.Fatal(err) } if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil { -- 2.40.1 From 9f478dac1db5ad3295f619728f70e6f81dfd4645 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Tue, 25 Jul 2023 15:08:32 +0200 Subject: [PATCH 4/4] fix: list downgrades/upgrades in correct order Now that we have correct sorting of versions: https://git.coopcloud.tech/coop-cloud/organising/issues/427 We don't need to reverse sort. Only for showing prompts when the latest should be the first. Otherwise, logic can follow the sorted order, the last item in the list is the latest upgrade. Related: https://git.coopcloud.tech/coop-cloud/organising/issues/444 Also fix `upgrade` to actually show the latest version --- cli/app/rollback.go | 8 +++----- cli/app/upgrade.go | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cli/app/rollback.go b/cli/app/rollback.go index d3f7c61f..756d4729 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -124,17 +124,15 @@ recipes. } } - availableDowngrades = internal.ReverseStringList(availableDowngrades) - var chosenDowngrade string - if !internal.Chaos { + if len(availableDowngrades) > 0 && !internal.Chaos { if internal.Force || internal.NoInput { - chosenDowngrade = availableDowngrades[0] + chosenDowngrade = availableDowngrades[len(availableDowngrades)-1] logrus.Debugf("choosing %s as version to downgrade to (--force)", chosenDowngrade) } else { prompt := &survey.Select{ Message: fmt.Sprintf("Please select a downgrade (current version: %s):", deployedVersion), - Options: availableDowngrades, + Options: internal.ReverseStringList(availableDowngrades), } if err := survey.AskOne(prompt, &chosenDowngrade); err != nil { return err diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 85fd8e8c..3c39baf7 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -127,8 +127,6 @@ recipes. } } - availableUpgrades = internal.ReverseStringList(availableUpgrades) - var chosenUpgrade string if len(availableUpgrades) > 0 && !internal.Chaos { if internal.Force || internal.NoInput { @@ -137,7 +135,7 @@ recipes. } else { prompt := &survey.Select{ Message: fmt.Sprintf("Please select an upgrade (current version: %s):", deployedVersion), - Options: availableUpgrades, + Options: internal.ReverseStringList(availableUpgrades), } if err := survey.AskOne(prompt, &chosenUpgrade); err != nil { return err -- 2.40.1