From a470d1cf9a0d5172740c0c8966a055e1c91b6a65 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Tue, 10 Mar 2020 07:39:42 -0700 Subject: [PATCH] Add warning if disk image is missing features --- pkg/minikube/cruntime/docker.go | 15 ++++++++++++++- pkg/minikube/node/config.go | 8 +++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index c27d7e84ea36..41d1385a3ed9 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -33,6 +33,19 @@ import ( // KubernetesContainerPrefix is the prefix of each kubernetes container const KubernetesContainerPrefix = "k8s_" +type ErrISOFeature struct { + missing string +} + +func NewErrISOFeature(missing string) *ErrISOFeature { + return &ErrISOFeature{ + missing: missing, + } +} +func (e *ErrISOFeature) Error() string { + return e.missing +} + // Docker contains Docker runtime state type Docker struct { Socket string @@ -278,7 +291,7 @@ func (r *Docker) Preload(k8sVersion string) error { c := exec.Command("which", "lz4") if _, err := r.Runner.RunCmd(c); err != nil { - return errors.Wrapf(err, "check lz4 available.") + return NewErrISOFeature("lz4") } // Copy over tarball into host diff --git a/pkg/minikube/node/config.go b/pkg/minikube/node/config.go index 14ad22ae8f5d..e93a7fc4d87b 100644 --- a/pkg/minikube/node/config.go +++ b/pkg/minikube/node/config.go @@ -68,7 +68,13 @@ func configureRuntimes(runner cruntime.CommandRunner, drvName string, k8s config } if !driver.IsKIC(drvName) { if err := cr.Preload(k8s.KubernetesVersion); err != nil { - glog.Errorf("Failed to preload container runtime %s: %v, falling back to caching images", cr.Name(), err) + switch err.(type) { + case *cruntime.ErrISOFeature: + out.T(out.Tip, "Existing disk is missing new features ({{.error}}). To upgrade, run 'minikube delete'", out.V{"error": err}) + default: + glog.Warningf("%s preload failed: %v, falling back to caching images", cr.Name(), err) + } + if err := machine.CacheImagesForBootstrapper(k8s.ImageRepository, k8s.KubernetesVersion, viper.GetString(cmdcfg.Bootstrapper)); err != nil { exit.WithError("Failed to cache images", err) }