Skip to content

Commit

Permalink
feat: check if target version existed before upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
fengluodb committed Nov 21, 2023
1 parent 756333e commit 6e08a9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/kubeblocks/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,9 @@ func (o *InstallOptions) checkVersion(v util.Version) error {
// check installing version exists
if exists, err := versionExists(o.Version); !exists {
if err != nil {
klog.V(1).Infof(err.Error())
return err
}
return errors.Wrapf(err, "version %s does not exist, please use \"kbcli kubeblocks list-versions --devel\" to show the available versions", o.Version)
return fmt.Errorf("version %s does not exist, please use \"kbcli kubeblocks list-versions --devel\" to show the available versions", o.Version)
}

versionErr := fmt.Errorf("failed to get kubernetes version")
Expand Down
8 changes: 8 additions & 0 deletions pkg/cmd/kubeblocks/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ func (o *InstallOptions) Upgrade() error {
}
fmt.Fprintf(o.Out, "Current KubeBlocks version %s.\n", v.KubeBlocks)

// check installing version exists
if exists, err := versionExists(o.Version); !exists {
if err != nil {
return err
}
return fmt.Errorf("version %s does not exist, please use \"kbcli kubeblocks list-versions --devel\" to show the available versions", o.Version)
}

if err = o.checkVersion(v); err != nil {
return err
}
Expand Down

0 comments on commit 6e08a9f

Please sign in to comment.