From de45f94401231df539ca3f1fad38dc2bbc2d1bf6 Mon Sep 17 00:00:00 2001 From: Thomas Stromberg Date: Fri, 10 Apr 2020 12:32:43 -0700 Subject: [PATCH] Skip containerd shutdown if Docker is bound to it --- pkg/minikube/cruntime/cruntime.go | 10 ++++++++++ pkg/minikube/cruntime/docker.go | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go index 9bde921993e1..bbb410be131e 100644 --- a/pkg/minikube/cruntime/cruntime.go +++ b/pkg/minikube/cruntime/cruntime.go @@ -166,6 +166,7 @@ func ContainerStatusCommand() string { // disableOthers disables all other runtimes except for me. func disableOthers(me Manager, cr CommandRunner) error { + // valid values returned by manager.Name() runtimes := []string{"containerd", "crio", "docker"} for _, name := range runtimes { @@ -178,13 +179,22 @@ func disableOthers(me Manager, cr CommandRunner) error { if r.Name() == me.Name() { continue } + + // Don't disable containerd if we are bound to it + if me.Name() == "Docker" && r.Name() == "containerd" && dockerBoundToContainerd(cr) { + glog.Infof("skipping containerd shutdown because we are bound to it") + continue + } + // runtime is already disabled, nothing to do. if !r.Active() { continue } + if err = r.Disable(); err != nil { glog.Warningf("disable failed: %v", err) } + // Validate that the runtime really is offline - and that Active & Disable are properly written. if r.Active() { return fmt.Errorf("%s is still active", r.Name()) diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 236ae3510ac9..95f855415235 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -364,3 +364,18 @@ func DockerImagesPreloaded(runner command.Runner, images []string) bool { } return true } + +func dockerBoundToContainerd(runner command.Runner) bool { + // NOTE: assumes systemd + rr, err := runner.RunCmd(exec.Command("sudo", "systemctl", "cat", "docker.service")) + if err != nil { + glog.Warningf("unable to check if docker is bound to containerd") + return false + } + + if strings.Contains(rr.Stdout.String(), "\nBindsTo=containerd") { + return true + } + + return false +}