Skip to content

Commit

Permalink
Merge pull request #8518 from afbjorklund/docker-containerd
Browse files Browse the repository at this point in the history
Make sure to use internal containerd for docker
  • Loading branch information
medyagh authored Jun 23, 2020
2 parents b1c26a2 + 4027ba4 commit 4f6a9f6
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 21 deletions.
71 changes: 50 additions & 21 deletions pkg/minikube/cruntime/cruntime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,16 @@ func (f *FakeRunner) systemctl(args []string, root bool) (string, error) { // no
return out, nil
}
return out, fmt.Errorf("%s in state: %v", svc, state)
case "cat":
f.t.Logf("fake systemctl: %s cat: %v", svc, state)
if svc == "docker.service" {
out += "[Unit]\n"
out += "Description=Docker Application Container Engine\n"
out += "Documentation=https://docs.docker.com\n"
//out += "BindsTo=containerd.service\n"
return out, nil
}
return out, fmt.Errorf("%s cat unimplemented", svc)
default:
return out, fmt.Errorf("unimplemented fake action: %q", action)
}
Expand Down Expand Up @@ -526,6 +536,14 @@ var defaultServices = map[string]serviceState{
"containerd": SvcExited,
}

// allServices reflects the state of all actual services running at once
var allServices = map[string]serviceState{
"docker": SvcRunning,
"crio": SvcRunning,
"crio-shutdown": SvcExited,
"containerd": SvcRunning,
}

func TestDisable(t *testing.T) {
var tests = []struct {
runtime string
Expand Down Expand Up @@ -558,32 +576,43 @@ func TestDisable(t *testing.T) {

func TestEnable(t *testing.T) {
var tests = []struct {
runtime string
want map[string]serviceState
runtime string
services map[string]serviceState
want map[string]serviceState
}{
{"docker", map[string]serviceState{
"docker": SvcRunning,
"containerd": SvcExited,
"crio": SvcExited,
"crio-shutdown": SvcExited,
}},
{"containerd", map[string]serviceState{
"docker": SvcExited,
"containerd": SvcRestarted,
"crio": SvcExited,
"crio-shutdown": SvcExited,
}},
{"crio", map[string]serviceState{
"docker": SvcExited,
"containerd": SvcExited,
"crio": SvcRunning,
"crio-shutdown": SvcExited,
}},
{"docker", defaultServices,
map[string]serviceState{
"docker": SvcRunning,
"containerd": SvcExited,
"crio": SvcExited,
"crio-shutdown": SvcExited,
}},
{"docker", allServices,
map[string]serviceState{
"docker": SvcRestarted,
"containerd": SvcExited,
"crio": SvcExited,
"crio-shutdown": SvcExited,
}},
{"containerd", defaultServices,
map[string]serviceState{
"docker": SvcExited,
"containerd": SvcRestarted,
"crio": SvcExited,
"crio-shutdown": SvcExited,
}},
{"crio", defaultServices,
map[string]serviceState{
"docker": SvcExited,
"containerd": SvcExited,
"crio": SvcRunning,
"crio-shutdown": SvcExited,
}},
}
for _, tc := range tests {
t.Run(tc.runtime, func(t *testing.T) {
runner := NewFakeRunner(t)
for k, v := range defaultServices {
for k, v := range tc.services {
runner.services[k] = v
}
cr, err := New(Config{Type: tc.runtime, Runner: runner})
Expand Down
7 changes: 7 additions & 0 deletions pkg/minikube/cruntime/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func (r *Docker) Active() bool {

// Enable idempotently enables Docker on a host
func (r *Docker) Enable(disOthers, forceSystemd bool) error {
containerdWasActive := r.Init.Active("containerd")

if disOthers {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
Expand All @@ -117,6 +119,11 @@ func (r *Docker) Enable(disOthers, forceSystemd bool) error {
return r.Init.Restart("docker")
}

if containerdWasActive && !dockerBoundToContainerd(r.Runner) {
// Make sure to use the internal containerd
return r.Init.Restart("docker")
}

return r.Init.Start("docker")
}

Expand Down

0 comments on commit 4f6a9f6

Please sign in to comment.