Pass forceSystemd into cRuntime lib to avoid errors with cobra
parent
045b1e9a3a
commit
1087f56b7a
|
@ -197,12 +197,17 @@ func generateContainerdConfig(cr CommandRunner, imageRepository string, kv semve
|
|||
}
|
||||
|
||||
// Enable idempotently enables containerd on a host
|
||||
func (r *Containerd) Enable(disOthers bool) error {
|
||||
func (r *Containerd) Enable(disOthers, forceSystemd bool) error {
|
||||
if disOthers {
|
||||
if err := disableOthers(r, r.Runner); err != nil {
|
||||
glog.Warningf("disableOthers: %v", err)
|
||||
}
|
||||
}
|
||||
if forceSystemd {
|
||||
if err := r.ForceSystemd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -110,12 +110,17 @@ func (r *CRIO) Active() bool {
|
|||
}
|
||||
|
||||
// Enable idempotently enables CRIO on a host
|
||||
func (r *CRIO) Enable(disOthers bool) error {
|
||||
func (r *CRIO) Enable(disOthers, forceSystemd bool) error {
|
||||
if disOthers {
|
||||
if err := disableOthers(r, r.Runner); err != nil {
|
||||
glog.Warningf("disableOthers: %v", err)
|
||||
}
|
||||
}
|
||||
if forceSystemd {
|
||||
if err := r.ForceSystemd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ type Manager interface {
|
|||
// Version retrieves the current version of this runtime
|
||||
Version() (string, error)
|
||||
// Enable idempotently enables this runtime on a host
|
||||
Enable(bool) error
|
||||
Enable(bool, bool) error
|
||||
// Disable idempotently disables this runtime on a host
|
||||
Disable() error
|
||||
// Active returns whether or not a runtime is active on a host
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/minikube/assets"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
|
@ -104,15 +103,17 @@ func (r *Docker) Active() bool {
|
|||
}
|
||||
|
||||
// Enable idempotently enables Docker on a host
|
||||
func (r *Docker) Enable(disOthers bool) error {
|
||||
func (r *Docker) Enable(disOthers, forceSystemd bool) error {
|
||||
if disOthers {
|
||||
if err := disableOthers(r, r.Runner); err != nil {
|
||||
glog.Warningf("disableOthers: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.ForceSystemd(); err != nil {
|
||||
return errors.Wrap(err, "forcing systemd")
|
||||
if forceSystemd {
|
||||
if err := r.ForceSystemd(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return r.Init.Start("docker")
|
||||
|
@ -281,9 +282,6 @@ func (r *Docker) SystemLogCmd(len int) string {
|
|||
|
||||
// ForceSystemd forces the docker daemon to use systemd as cgroup manager
|
||||
func (r *Docker) ForceSystemd() error {
|
||||
if !viper.GetBool("force-systemd") {
|
||||
return nil
|
||||
}
|
||||
daemonConfig := `{
|
||||
"exec-opts": ["native.cgroupdriver=systemd"],
|
||||
"log-driver": "json-file",
|
||||
|
|
|
@ -255,7 +255,7 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
|
|||
}
|
||||
}
|
||||
|
||||
err = cr.Enable(disableOthers)
|
||||
err = cr.Enable(disableOthers, viper.GetBool("force-systemd"))
|
||||
if err != nil {
|
||||
debug.PrintStack()
|
||||
exit.WithError("Failed to enable container runtime", err)
|
||||
|
|
Loading…
Reference in New Issue