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

Add env variable to configure force-systemd #8010

Merged
merged 1 commit into from
May 5, 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
2 changes: 2 additions & 0 deletions pkg/minikube/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const (
MinikubeActiveDockerdEnv = "MINIKUBE_ACTIVE_DOCKERD"
// PodmanVarlinkBridgeEnv is used for podman settings
PodmanVarlinkBridgeEnv = "PODMAN_VARLINK_BRIDGE"
// MinikubeForceSystemdEnv is used to force systemd as cgroup manager for the container runtime
MinikubeForceSystemdEnv = "MINIKUBE_FORCE_SYSTEMD"
)

var (
Expand Down
6 changes: 5 additions & 1 deletion pkg/minikube/node/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
}
}

err = cr.Enable(disableOthers, viper.GetBool("force-systemd"))
err = cr.Enable(disableOthers, forceSystemd())
if err != nil {
debug.PrintStack()
exit.WithError("Failed to enable container runtime", err)
Expand All @@ -261,6 +261,10 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
return cr
}

func forceSystemd() bool {
return viper.GetBool("force-systemd") || os.Getenv(constants.MinikubeForceSystemdEnv) == "true"
}

// setupKubeAdm adds any requested files into the VM before Kubernetes is started
func setupKubeAdm(mAPI libmachine.API, cfg config.ClusterConfig, n config.Node, r command.Runner) bootstrapper.Bootstrapper {
bs, err := cluster.Bootstrapper(mAPI, viper.GetString(cmdcfg.Bootstrapper), cfg, r)
Expand Down
33 changes: 31 additions & 2 deletions test/integration/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package integration

import (
"context"
"os"
"os/exec"
"strings"
"testing"
Expand Down Expand Up @@ -64,13 +65,13 @@ func TestDockerFlags(t *testing.T) {
}
}

func TestForceSystemd(t *testing.T) {
func TestForceSystemdFlag(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
}
MaybeParallel(t)

profile := UniqueProfileName("force-systemd")
profile := UniqueProfileName("force-systemd-flag")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer CleanupWithLogs(t, profile, cancel)

Expand All @@ -90,3 +91,31 @@ func TestForceSystemd(t *testing.T) {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}

func TestForceSystemdEnv(t *testing.T) {
if NoneDriver() {
t.Skip("skipping: none driver does not support ssh or bundle docker")
}
MaybeParallel(t)

profile := UniqueProfileName("force-systemd-env")
ctx, cancel := context.WithTimeout(context.Background(), Minutes(30))
defer CleanupWithLogs(t, profile, cancel)

args := append([]string{"start", "-p", profile, "--memory=1800", "--alsologtostderr", "-v=5"}, StartArgs()...)
cmd := exec.CommandContext(ctx, Target(), args...)
cmd.Env = append(os.Environ(), "MINIKUBE_FORCE_SYSTEMD=true")
rr, err := Run(t, cmd)
if err != nil {
t.Errorf("failed to start minikube with args: %q : %v", rr.Command(), err)
}

rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "docker info --format {{.CgroupDriver}}"))
if err != nil {
t.Errorf("failed to get docker cgroup driver. args %q: %v", rr.Command(), err)
}

if !strings.Contains(rr.Output(), "systemd") {
t.Fatalf("expected systemd cgroup driver, got: %v", rr.Output())
}
}