Skip to content

Commit

Permalink
Merge pull request #7595 from tstromberg/containerd-bound
Browse files Browse the repository at this point in the history
Skip containerd shutdown if Docker is bound to it
  • Loading branch information
medyagh authored Apr 10, 2020
2 parents 30bf7bf + de45f94 commit aa8de05
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/minikube/cruntime/cruntime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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())
Expand Down
15 changes: 15 additions & 0 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit aa8de05

Please sign in to comment.