check container runtime version for upgrades
parent
9d65d85314
commit
dd5d8a36e6
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue