Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't attempt to pull docker images on relaunch #4129

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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