Skip to content

Commit

Permalink
don't attempt to pull docker images on relaunch when it's not an upgrade
Browse files Browse the repository at this point in the history
fix syntax
  • Loading branch information
marcosdiez committed Apr 25, 2019
1 parent 167ab2e commit 3eb340b
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand All @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 3eb340b

Please sign in to comment.