mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-06-03 01:44:53 +00:00
Fix wrong error message when upgrading recovery (#788)
* Fix wrong error message when upgrading recovery fix command help text and simplify variables in function Fixes https://github.com/kairos-io/kairos/issues/3393 Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> * Fix test Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me> --------- Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
2b1e5e66fb
commit
53c1b6c9ea
22
main.go
22
main.go
@ -75,12 +75,13 @@ var cmds = []*cli.Command{
|
||||
&cli.BoolFlag{Name: "recovery", Usage: "Upgrade recovery"},
|
||||
},
|
||||
Description: `
|
||||
Manually upgrade a kairos node Active image. Does not upgrade passive or recovery images.
|
||||
Manually upgrade a kairos node Active image. Does not upgrade the passive image. It upgrades the recovery image when the --recovery flag is passed.
|
||||
|
||||
With no arguments, it defaults to latest available release. To specify a version, pass it as argument using the --source flag.
|
||||
Passing just the Kairos version as the first argument is no longer supported. If you speficy a positional argument, it will be treated
|
||||
To specify a version, pass it as argument using the --source flag. Passing just the Kairos version as the first argument is no longer supported. If you speficy a positional argument, it will be treated
|
||||
as a value for the --source flag.
|
||||
|
||||
You can also specify the upgrade image by setting "upgrade.system.uri" for the active image or "upgrade.recovery-system.uri" for the recovery image, in the cloud config.
|
||||
|
||||
To retrieve all the available versions, use "kairos upgrade list-releases"
|
||||
|
||||
$ kairos upgrade list-releases
|
||||
@ -167,24 +168,21 @@ See https://kairos.io/docs/upgrade/manual/ for documentation.
|
||||
return checkRoot()
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
var v string
|
||||
var source string
|
||||
if c.Args().Len() == 1 {
|
||||
v = c.Args().First()
|
||||
fmt.Println("Warning: Passing a version as a positional argument is deprecated. Use --source flag instead.")
|
||||
fmt.Println("The value will be used as a value for the --source flag")
|
||||
source = c.Args().First()
|
||||
}
|
||||
|
||||
if v := c.String("source"); v != "" {
|
||||
source = v
|
||||
}
|
||||
|
||||
image := c.String("image")
|
||||
if v := c.String("source"); v != "" {
|
||||
source = c.String("source")
|
||||
}
|
||||
|
||||
if image != "" {
|
||||
if v := c.String("image"); v != "" {
|
||||
fmt.Println("--image flag is deprecated, please use --source")
|
||||
// override source with image for now until we drop it
|
||||
source = fmt.Sprintf("oci:%s", image)
|
||||
source = fmt.Sprintf("oci:%s", v)
|
||||
}
|
||||
|
||||
if c.Bool("recovery") && c.String("boot-entry") != "" {
|
||||
|
@ -126,7 +126,8 @@ const (
|
||||
StateResetBootSuffix = " state reset (auto)"
|
||||
|
||||
// Error
|
||||
UpgradeNoSourceError = "Could not find a proper source for the upgrade.\nThis can be configured in the cloud config files under the 'upgrade.system.uri' key or via cmdline using the '--source' flag."
|
||||
UpgradeNoSourceError = "could not find a proper source for the upgrade.\nThis can be configured in the cloud config files under the 'upgrade.system.uri' key or via cmdline using the '--source' flag"
|
||||
UpgradeRecoveryNoSourceError = "could not find a proper source for the recovery upgrade.\nThis can be configured in the cloud config files under the 'upgrade.recovery-system.uri' key or via cmdline using the '--source' flag"
|
||||
MultipleEntriesAssessmentError = "multiple boot entries found for %s"
|
||||
NoBootAssessmentWarning = "No boot assessment found in current boot entry config file"
|
||||
)
|
||||
|
@ -190,7 +190,7 @@ func (u *UpgradeSpec) RecoveryUpgrade() bool {
|
||||
func (u *UpgradeSpec) Sanitize() error {
|
||||
if u.RecoveryUpgrade() {
|
||||
if u.Recovery.Source.IsEmpty() {
|
||||
return fmt.Errorf(constants.UpgradeNoSourceError)
|
||||
return fmt.Errorf(constants.UpgradeRecoveryNoSourceError)
|
||||
}
|
||||
if u.Partitions.Recovery == nil || u.Partitions.Recovery.MountPoint == "" {
|
||||
return fmt.Errorf("undefined recovery partition")
|
||||
|
@ -17,9 +17,10 @@ limitations under the License.
|
||||
package v1_test
|
||||
|
||||
import (
|
||||
sdkTypes "github.com/kairos-io/kairos-sdk/types"
|
||||
"path/filepath"
|
||||
|
||||
sdkTypes "github.com/kairos-io/kairos-sdk/types"
|
||||
|
||||
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
@ -451,7 +452,7 @@ var _ = Describe("Types", Label("types", "config"), func() {
|
||||
It("fails with empty source", func() {
|
||||
err := spec.Sanitize()
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err.Error()).To(ContainSubstring(constants.UpgradeNoSourceError))
|
||||
Expect(err.Error()).To(ContainSubstring(constants.UpgradeRecoveryNoSourceError))
|
||||
})
|
||||
It("fails with missing recovery partition", func() {
|
||||
spec.Recovery.Source = v1.NewFileSrc("/tmp")
|
||||
|
Loading…
Reference in New Issue
Block a user