diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go index 7bee38519f..3732247c3b 100644 --- a/pkg/minikube/cruntime/cruntime.go +++ b/pkg/minikube/cruntime/cruntime.go @@ -243,3 +243,19 @@ func disableOthers(me Manager, cr CommandRunner) error { } return nil } + +var requiredContainerdVersion = semver.MustParse("1.4.0") + +// CompatibleWithCurrent checks if current version of "runtime" is compatible with "v" +func CompatibleWithCurrent(runtime, v string) (bool, error) { + vv, err := semver.Make(v) + if err != nil { + return false, err + } + switch runtime { + case "containerd": + return requiredContainerdVersion.LE(vv), nil + default: + return true, nil + } +} diff --git a/pkg/minikube/node/start.go b/pkg/minikube/node/start.go index 7f0a97471c..ffef8ac087 100644 --- a/pkg/minikube/node/start.go +++ b/pkg/minikube/node/start.go @@ -97,6 +97,12 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { // configure the runtime (docker, containerd, crio) cr := configureRuntimes(starter.Runner, *starter.Cfg, sv) + + // check if installed runtime is compatible with current minikube code + if err = validateRuntimeVersion(err, cr); err != nil { + return nil, err + } + showVersionInfo(starter.Node.KubernetesVersion, cr) // Add "host.minikube.internal" DNS alias (intentionally non-fatal) @@ -223,6 +229,21 @@ func Start(starter Starter, apiServer bool) (*kubeconfig.Settings, error) { return kcs, config.Write(viper.GetString(config.ProfileName), starter.Cfg) } +func validateRuntimeVersion(err error, cr cruntime.Manager) error { + v, err := cr.Version() + if err != nil { + return errors.Wrap(err, "Failed to check container runtime version") + } + ok, err := cruntime.CompatibleWithCurrent(cr.Name(), v) + if err != nil { + return errors.Wrap(err, "Failed to validate container runtime version") + } + if !ok { + return fmt.Errorf( "version %s of %s is not compatible with current", v, cr.Name()) + } + return nil +} + // joinCluster adds new or prepares and then adds existing node to the cluster. func joinCluster(starter Starter, cpBs bootstrapper.Bootstrapper, bs bootstrapper.Bootstrapper) error { start := time.Now() @@ -353,7 +374,6 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k if err != nil { exit.Error(reason.RuntimeEnable, "Failed to start container runtime", err) } - return cr }