Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to use internal containerd for docker #8518

Merged
merged 4 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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