From ba2053410747d01199e900ec0ea4702f666e590d Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Thu, 20 Jun 2019 13:06:22 -0300 Subject: [PATCH 1/5] we don't disable other container engines when vmdriver==none --- cmd/minikube/cmd/start.go | 3 ++- pkg/minikube/cruntime/containerd.go | 8 +++++--- pkg/minikube/cruntime/crio.go | 8 +++++--- pkg/minikube/cruntime/cruntime.go | 2 +- pkg/minikube/cruntime/docker.go | 8 +++++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index b01f3e5c7d12..24a5dee2757d 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -684,7 +684,8 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager { exit.WithError(fmt.Sprintf("Failed runtime for %+v", config), err) } - err = cr.Enable() + disableOtherContainerEngines := viper.GetString(vmDriver) != constants.DriverNone + err = cr.Enable(disableOtherContainerEngines) if err != nil { exit.WithError("Failed to enable container runtime", err) } diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index fead3bdfbe56..a2710871630f 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -79,9 +79,11 @@ func (r *Containerd) Available() error { } // Enable idempotently enables containerd on a host -func (r *Containerd) Enable() error { - if err := disableOthers(r, r.Runner); err != nil { - glog.Warningf("disableOthers: %v", err) +func (r *Containerd) Enable(disableOtherContainerEngines bool) error { + if disableOtherContainerEngines { + if err := disableOthers(r, r.Runner); err != nil { + glog.Warningf("disableOthers: %v", err) + } } if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil { return err diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 5779a651c9fb..262267e0257e 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -78,9 +78,11 @@ func (r *CRIO) Active() bool { } // Enable idempotently enables CRIO on a host -func (r *CRIO) Enable() error { - if err := disableOthers(r, r.Runner); err != nil { - glog.Warningf("disableOthers: %v", err) +func (r *CRIO) Enable(disableOtherContainerEngines bool) error { + if disableOtherContainerEngines { + if err := disableOthers(r, r.Runner); err != nil { + glog.Warningf("disableOthers: %v", err) + } } if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil { return err diff --git a/pkg/minikube/cruntime/cruntime.go b/pkg/minikube/cruntime/cruntime.go index a17699e88af0..ef8bea140dfe 100644 --- a/pkg/minikube/cruntime/cruntime.go +++ b/pkg/minikube/cruntime/cruntime.go @@ -38,7 +38,7 @@ type Manager interface { // Version retrieves the current version of this runtime Version() (string, error) // Enable idempotently enables this runtime on a host - Enable() error + Enable(bool) error // Disable idempotently disables this runtime on a host Disable() error // Active returns whether or not a runtime is active on a host diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index c5ad92261c5b..989286ee5c78 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -75,9 +75,11 @@ func (r *Docker) Active() bool { } // Enable idempotently enables Docker on a host -func (r *Docker) Enable() error { - if err := disableOthers(r, r.Runner); err != nil { - glog.Warningf("disableOthers: %v", err) +func (r *Docker) Enable(disableOtherContainerEngines bool) error { + if disableOtherContainerEngines { + if err := disableOthers(r, r.Runner); err != nil { + glog.Warningf("disableOthers: %v", err) + } } return r.Runner.Run("sudo systemctl start docker") } From 1d3c6832f9bcbb9d8ee593e348dd5e109a1f2f30 Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Thu, 20 Jun 2019 13:26:16 -0300 Subject: [PATCH 2/5] fix tests --- pkg/minikube/cruntime/cruntime_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/minikube/cruntime/cruntime_test.go b/pkg/minikube/cruntime/cruntime_test.go index c4c49bb15b4c..a43926912118 100644 --- a/pkg/minikube/cruntime/cruntime_test.go +++ b/pkg/minikube/cruntime/cruntime_test.go @@ -406,7 +406,7 @@ func TestEnable(t *testing.T) { if err != nil { t.Fatalf("New(%s): %v", tc.runtime, err) } - err = cr.Enable() + err = cr.Enable(true) if err != nil { t.Errorf("%s disable unexpected error: %v", tc.runtime, err) } From f802c19eeb0421fe1fd59e5e9f483144fc4098cc Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Mon, 24 Jun 2019 09:01:53 -0300 Subject: [PATCH 3/5] making code more readable --- cmd/minikube/cmd/start.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 24a5dee2757d..a21c84d8f777 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -684,8 +684,11 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager { exit.WithError(fmt.Sprintf("Failed runtime for %+v", config), err) } - disableOtherContainerEngines := viper.GetString(vmDriver) != constants.DriverNone - err = cr.Enable(disableOtherContainerEngines) + disableOthers := true + if viper.GetString(vmDriver) == constants.DriverNone { + disableOthers = false + } + err = cr.Enable(disableOthers) if err != nil { exit.WithError("Failed to enable container runtime", err) } From 820f7984dad2604bd4d56fac7f5f3e0deb0762d9 Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Mon, 24 Jun 2019 11:54:20 -0300 Subject: [PATCH 4/5] go fmt --- cmd/minikube/cmd/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index a21c84d8f777..d450b77725d8 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -685,7 +685,7 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager { } disableOthers := true - if viper.GetString(vmDriver) == constants.DriverNone { + if viper.GetString(vmDriver) == constants.DriverNone { disableOthers = false } err = cr.Enable(disableOthers) From f0c39588a2d36acac0272e162fd0d1893187027c Mon Sep 17 00:00:00 2001 From: Marcos Diez Date: Wed, 26 Jun 2019 07:25:10 -0300 Subject: [PATCH 5/5] rename variable --- pkg/minikube/cruntime/containerd.go | 4 ++-- pkg/minikube/cruntime/crio.go | 4 ++-- pkg/minikube/cruntime/docker.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/minikube/cruntime/containerd.go b/pkg/minikube/cruntime/containerd.go index 72afc09caa39..20ec4e27da55 100644 --- a/pkg/minikube/cruntime/containerd.go +++ b/pkg/minikube/cruntime/containerd.go @@ -80,8 +80,8 @@ func (r *Containerd) Available() error { } // Enable idempotently enables containerd on a host -func (r *Containerd) Enable(disableOtherContainerEngines bool) error { - if disableOtherContainerEngines { +func (r *Containerd) Enable(disOthers bool) error { + if disOthers { if err := disableOthers(r, r.Runner); err != nil { glog.Warningf("disableOthers: %v", err) } diff --git a/pkg/minikube/cruntime/crio.go b/pkg/minikube/cruntime/crio.go index 6d187f91f6d3..67b86fac182d 100644 --- a/pkg/minikube/cruntime/crio.go +++ b/pkg/minikube/cruntime/crio.go @@ -78,8 +78,8 @@ func (r *CRIO) Active() bool { } // Enable idempotently enables CRIO on a host -func (r *CRIO) Enable(disableOtherContainerEngines bool) error { - if disableOtherContainerEngines { +func (r *CRIO) Enable(disOthers bool) error { + if disOthers { if err := disableOthers(r, r.Runner); err != nil { glog.Warningf("disableOthers: %v", err) } diff --git a/pkg/minikube/cruntime/docker.go b/pkg/minikube/cruntime/docker.go index 24b48c64faa4..393df82d518e 100644 --- a/pkg/minikube/cruntime/docker.go +++ b/pkg/minikube/cruntime/docker.go @@ -75,8 +75,8 @@ func (r *Docker) Active() bool { } // Enable idempotently enables Docker on a host -func (r *Docker) Enable(disableOtherContainerEngines bool) error { - if disableOtherContainerEngines { +func (r *Docker) Enable(disOthers bool) error { + if disOthers { if err := disableOthers(r, r.Runner); err != nil { glog.Warningf("disableOthers: %v", err) }