From 3eb340b5271dc3081432dc621f99781e3d6af8e0 Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Mon, 22 Apr 2019 09:12:43 -0300 Subject: [PATCH] don't attempt to pull docker images on relaunch when it's not an upgrade fix syntax --- cmd/minikube/cmd/start.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 137d3308fd33..6c82324f2062 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -170,7 +170,7 @@ func runStart(cmd *cobra.Command, args []string) { if err != nil && !os.IsNotExist(err) { exit.WithCode(exit.Data, "Unable to load config: %v", err) } - k8sVersion := validateKubernetesVersions(oldConfig) + k8sVersion, isUpgrade := validateKubernetesVersions(oldConfig) config, err := generateConfig(cmd, k8sVersion) if err != nil { exit.WithError("Failed to generate config", err) @@ -236,7 +236,7 @@ func runStart(cmd *cobra.Command, args []string) { // The kube config must be update must come before bootstrapping, otherwise health checks may use a stale IP kubeconfig := updateKubeConfig(host, &config) - bootstrapCluster(bs, cr, runner, config.KubernetesConfig, preexisting) + bootstrapCluster(bs, cr, runner, config.KubernetesConfig, preexisting, isUpgrade) apiserverPort := config.KubernetesConfig.NodePort validateCluster(bs, cr, runner, ip, apiserverPort) @@ -459,8 +459,9 @@ func validateNetwork(h *host.Host) string { } // validateKubernetesVersions ensures that the requested version is reasonable -func validateKubernetesVersions(old *cfg.Config) string { +func validateKubernetesVersions(old *cfg.Config) (string, bool) { nv := viper.GetString(kubernetesVersion) + isUpgrade := false if nv == "" { nv = constants.DefaultKubernetesVersion } @@ -470,7 +471,7 @@ func validateKubernetesVersions(old *cfg.Config) string { } if old == nil || old.KubernetesConfig.KubernetesVersion == "" { - return nv + return nv, isUpgrade } ovs, err := semver.Make(strings.TrimPrefix(old.KubernetesConfig.KubernetesVersion, version.VersionPrefix)) @@ -481,12 +482,13 @@ func validateKubernetesVersions(old *cfg.Config) string { if nvs.LT(ovs) { nv = version.VersionPrefix + ovs.String() console.ErrStyle("conflict", "Kubernetes downgrade is not supported, will continue to use %v", nv) - return nv + return nv, isUpgrade } if nvs.GT(ovs) { console.OutStyle("thumbs-up", "minikube will upgrade the local cluster from Kubernetes %s to %s", ovs, nvs) + isUpgrade = true } - return nv + return nv, isUpgrade } // prepareHostEnvironment adds any requested files into the VM before Kubernetes is started @@ -564,14 +566,17 @@ func configureRuntimes(h *host.Host, runner bootstrapper.CommandRunner) cruntime } // bootstrapCluster starts Kubernetes using the chosen bootstrapper -func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, kc cfg.KubernetesConfig, preexisting bool) { - console.OutStyle("pulling", "Pulling images required by Kubernetes %s ...", kc.KubernetesVersion) - if err := bs.PullImages(kc); err != nil { - console.OutStyle("failure", "Unable to pull images, which may be OK: %v", err) - } +func bootstrapCluster(bs bootstrapper.Bootstrapper, r cruntime.Manager, runner bootstrapper.CommandRunner, kc cfg.KubernetesConfig, preexisting bool, isUpgrade bool) { // hum. bootstrapper.Bootstrapper should probably have a Name function. bsName := viper.GetString(cmdcfg.Bootstrapper) + if isUpgrade || !preexisting { + console.OutStyle("pulling", "Pulling images required by Kubernetes %s ...", kc.KubernetesVersion) + if err := bs.PullImages(kc); err != nil { + console.OutStyle("failure", "Unable to pull images, which may be OK: %v", err) + } + } + if preexisting { console.OutStyle("restarting", "Relaunching Kubernetes %s using %s ... ", kc.KubernetesVersion, bsName) if err := bs.RestartCluster(kc); err != nil {