use systemd

pull/15463/head
Predrag Rogic 2022-12-12 00:49:23 +00:00
parent 0fa75ce152
commit 4cd9a94637
No known key found for this signature in database
GPG Key ID: F1FF5748C4855229
5 changed files with 49 additions and 11 deletions

View File

@ -219,7 +219,7 @@ func (r *CRIO) Enable(disOthers, forceSystemd, inUserNamespace bool) error {
} }
} }
// NOTE: before we start crio explicitly here, crio might be already started automatically // NOTE: before we start crio explicitly here, crio might be already started automatically
return r.Init.Start("crio") return r.Init.Restart("crio")
} }
// Disable idempotently disables CRIO on a host // Disable idempotently disables CRIO on a host

View File

@ -685,7 +685,7 @@ func TestEnable(t *testing.T) {
map[string]serviceState{ map[string]serviceState{
"docker": SvcExited, "docker": SvcExited,
"containerd": SvcExited, "containerd": SvcExited,
"crio": SvcRunning, "crio": SvcRestarted,
"crio-shutdown": SvcExited, "crio-shutdown": SvcExited,
}}, }},
} }

View File

@ -164,7 +164,7 @@ func (r *Docker) Enable(disOthers, forceSystemd, inUserNamespace bool) error {
if err := r.Init.Enable(r.CRIService); err != nil { if err := r.Init.Enable(r.CRIService); err != nil {
return err return err
} }
if err := r.Init.Start(r.CRIService); err != nil { if err := r.Init.Restart(r.CRIService); err != nil {
return err return err
} }
} }

View File

@ -468,10 +468,16 @@ func configureRuntimes(runner cruntime.CommandRunner, cc config.ClusterConfig, k
func forceSystemd(kv semver.Version) bool { func forceSystemd(kv semver.Version) bool {
// starting from k8s v1.22: "kubeadm clusters should be using the systemd driver" // starting from k8s v1.22: "kubeadm clusters should be using the systemd driver"
// ref: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.22.md#no-really-you-must-read-this-before-you-upgrade // ref: https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG/CHANGELOG-1.22.md#no-really-you-must-read-this-before-you-upgrade
// ref: https://kubernetes.io/docs/setup/production-environment/container-runtimes/#cgroup-drivers
// ref: https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/
// still, respect user preference, if present // still, respect user preference, if present
return kv.GTE(semver.Version{Major: 1, Minor: 22}) && if viper.IsSet("force-systemd") {
os.Getenv(constants.MinikubeForceSystemdEnv) != "false" && return viper.GetBool("force-systemd")
(!viper.IsSet("force-systemd") || viper.GetBool("force-systemd")) }
if env := os.Getenv(constants.MinikubeForceSystemdEnv); env != "" {
return env == "true"
}
return kv.GTE(semver.Version{Major: 1, Minor: 22})
} }
func pathExists(runner cruntime.CommandRunner, path string) (bool, error) { func pathExists(runner cruntime.CommandRunner, path string) (bool, error) {

View File

@ -377,21 +377,29 @@ func debugLogs(profile string) string {
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: /var/lib/kubelet/config.yaml:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: /var/lib/kubelet/config.yaml:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo", "find /etc/cni -type f -exec sh -c 'echo {}; cat {}' \\;") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo find /etc/cni -type f -exec sh -c 'echo {}; cat {}' \\;")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: /etc/cni:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: /etc/cni:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status docker | cat") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status docker | cat")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: docker svc:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: docker daemon:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status containerd | cat") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo cat /etc/docker/daemon.json")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: containerd svc:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: /etc/docker/daemon.json:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo docker system info")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: docker system info:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status cri-docker | cat") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status cri-docker | cat")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: cri-docker svc:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: cri daemon:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo cat /usr/lib/systemd/system/cri-docker.service")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: /usr/lib/systemd/system/cri-docker.service:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo cat /etc/systemd/system/cri-docker.service.d/10-cni.conf") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo cat /etc/systemd/system/cri-docker.service.d/10-cni.conf")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
@ -401,6 +409,30 @@ func debugLogs(profile string) string {
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: cri-dockerd version:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: cri-dockerd version:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status containerd | cat")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: containerd daemon:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo cat /etc/containerd/config.toml")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: /etc/containerd/config.toml:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo containerd config dump")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: containerd config dump:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo systemctl status crio | cat")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: crio daemon:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo find /etc/crio -type f -exec sh -c 'echo {}; cat {}' \\;")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: /etc/crio:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo crio config")
out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: crio config:\n%s\n", out))
cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo ip a s") cmd = exec.Command(Target(), "ssh", "-p", profile, "sudo ip a s")
out, _ = cmd.CombinedOutput() out, _ = cmd.CombinedOutput()
output.WriteString(fmt.Sprintf("\n>>> host: ip a s:\n%s\n", out)) output.WriteString(fmt.Sprintf("\n>>> host: ip a s:\n%s\n", out))