fix(cli): Make upgrade check if cluster reachable

The 'helm upgrade' command was not checking if the cluster was reachable.
Also, 'helm upgrade --install' first checks if the release exists
already.  If that check fails there is no point in continuing the
upgrade.  This optimization avoids a second timeout of 30 seconds when
trying to do the upgrade.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
pull/7367/head
Marc Khouzam 4 years ago committed by Marc Khouzam
parent 2dfb20f332
commit 22b7562c62

@ -91,8 +91,7 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
if client.Install {
// If a release does not exist, install it. If another error occurs during
// the check, ignore the error and continue with the upgrade.
// If a release does not exist, install it.
histClient := action.NewHistory(cfg)
histClient.Max = 1
if _, err := histClient.Run(args[0]); err == driver.ErrReleaseNotFound {
@ -119,6 +118,8 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
return err
}
return outfmt.Write(out, &statusPrinter{rel, settings.Debug})
} else if err != nil {
return err
}
}

@ -75,6 +75,10 @@ func NewUpgrade(cfg *Configuration) *Upgrade {
// Run executes the upgrade on the given release.
func (u *Upgrade) Run(name string, chart *chart.Chart, vals map[string]interface{}) (*release.Release, error) {
if err := u.cfg.KubeClient.IsReachable(); err != nil {
return nil, err
}
// Make sure if Atomic is set, that wait is set as well. This makes it so
// the user doesn't have to specify both
u.Wait = u.Wait || u.Atomic

Loading…
Cancel
Save