Merge branch 'master' of github.com:kubernetes/minikube into windows-mount
commit
23e7989c07
|
@ -145,15 +145,39 @@ func CreateContainerNode(p CreateParams) error {
|
|||
// label th enode wuth the node ID
|
||||
"--label", p.NodeLabel,
|
||||
}
|
||||
memcgSwap := true
|
||||
if runtime.GOOS == "linux" {
|
||||
if _, err := os.Stat("/sys/fs/cgroup/memory/memsw.limit_in_bytes"); os.IsNotExist(err) {
|
||||
// requires CONFIG_MEMCG_SWAP_ENABLED or cgroup_enable=memory in grub
|
||||
glog.Warning("Your kernel does not support swap limit capabilities or the cgroup is not mounted.")
|
||||
memcgSwap = false
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
|
||||
var virtualization string
|
||||
if p.OCIBinary == Podman { // enable execing in /var
|
||||
// podman mounts var/lib with no-exec by default https://github.com/containers/libpod/issues/5103
|
||||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var:exec", p.Name))
|
||||
|
||||
if memcgSwap {
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory=%s", p.Memory))
|
||||
// Disable swap by setting the value to match
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory-swap=%s", p.Memory))
|
||||
}
|
||||
|
||||
virtualization = "podman" // VIRTUALIZATION_PODMAN
|
||||
}
|
||||
if p.OCIBinary == Docker {
|
||||
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var", p.Name))
|
||||
// ignore apparmore github actions docker: https://github.com/kubernetes/minikube/issues/7624
|
||||
runArgs = append(runArgs, "--security-opt", "apparmor=unconfined")
|
||||
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory=%s", p.Memory))
|
||||
// Disable swap by setting the value to match
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory-swap=%s", p.Memory))
|
||||
|
||||
virtualization = "docker" // VIRTUALIZATION_DOCKER
|
||||
}
|
||||
|
||||
cpuCfsPeriod := true
|
||||
|
@ -175,35 +199,6 @@ func CreateContainerNode(p CreateParams) error {
|
|||
runArgs = append(runArgs, fmt.Sprintf("--cpus=%s", p.CPUs))
|
||||
}
|
||||
|
||||
memcgSwap := true
|
||||
if runtime.GOOS == "linux" {
|
||||
if _, err := os.Stat("/sys/fs/cgroup/memory/memsw.limit_in_bytes"); os.IsNotExist(err) {
|
||||
// requires CONFIG_MEMCG_SWAP_ENABLED or cgroup_enable=memory in grub
|
||||
glog.Warning("Your kernel does not support swap limit capabilities or the cgroup is not mounted.")
|
||||
memcgSwap = false
|
||||
}
|
||||
}
|
||||
|
||||
if p.OCIBinary == Podman && memcgSwap { // swap is required for memory
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory=%s", p.Memory))
|
||||
// Disable swap by setting the value to match
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory-swap=%s", p.Memory))
|
||||
}
|
||||
|
||||
if p.OCIBinary == Docker {
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory=%s", p.Memory))
|
||||
// Disable swap by setting the value to match
|
||||
runArgs = append(runArgs, fmt.Sprintf("--memory-swap=%s", p.Memory))
|
||||
}
|
||||
|
||||
// https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
|
||||
var virtualization string
|
||||
if p.OCIBinary == Podman {
|
||||
virtualization = "podman" // VIRTUALIZATION_PODMAN
|
||||
}
|
||||
if p.OCIBinary == Docker {
|
||||
virtualization = "docker" // VIRTUALIZATION_DOCKER
|
||||
}
|
||||
runArgs = append(runArgs, "-e", fmt.Sprintf("%s=%s", "container", virtualization))
|
||||
|
||||
for key, val := range p.Envs {
|
||||
|
|
|
@ -39,8 +39,12 @@ func MaybeDisplayAdvice(err error, driver string) {
|
|||
|
||||
if errors.Is(err, oci.ErrExitedUnexpectedly) || errors.Is(err, oci.ErrDaemonInfo) {
|
||||
out.T(style.Tip, "If you are still interested to make {{.driver_name}} driver work. The following suggestions might help you get passed this issue:", out.V{"driver_name": driver})
|
||||
out.T(style.Empty, `
|
||||
- Prune unused {{.driver_name}} images, volumes and abandoned containers.`, out.V{"driver_name": driver})
|
||||
if driver == oci.Docker || driver == oci.Podman {
|
||||
out.T(style.Empty, `
|
||||
- Prune unused {{.driver_name}} images, volumes, networks and abandoned containers.
|
||||
|
||||
{{.driver_name}} system prune --volumes`, out.V{"driver_name": driver})
|
||||
}
|
||||
out.T(style.Empty, `
|
||||
- Restart your {{.driver_name}} service`, out.V{"driver_name": driver})
|
||||
if runtime.GOOS != "linux" {
|
||||
|
|
|
@ -36,6 +36,7 @@ import (
|
|||
"github.com/juju/mutex"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/viper"
|
||||
"k8s.io/minikube/pkg/drivers/kic/oci"
|
||||
"k8s.io/minikube/pkg/minikube/command"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
|
@ -218,17 +219,32 @@ func postStartValidations(h *host.Host, drvName string) {
|
|||
glog.Warningf("error getting command runner: %v", err)
|
||||
}
|
||||
|
||||
var kind reason.Kind
|
||||
var name string
|
||||
if drvName == oci.Docker {
|
||||
kind = reason.RsrcInsufficientDockerStorage
|
||||
name = "Docker"
|
||||
}
|
||||
if drvName == oci.Podman {
|
||||
kind = reason.RsrcInsufficientPodmanStorage
|
||||
name = "Podman"
|
||||
}
|
||||
if name == "" {
|
||||
glog.Warningf("unknown KIC driver: %v", drvName)
|
||||
return
|
||||
}
|
||||
|
||||
// make sure /var isn't full, as pod deployments will fail if it is
|
||||
percentageFull, err := DiskUsed(r, "/var")
|
||||
if err != nil {
|
||||
glog.Warningf("error getting percentage of /var that is free: %v", err)
|
||||
}
|
||||
if percentageFull >= 99 {
|
||||
exit.Message(reason.RsrcInsufficientDockerStorage, `Docker is out of disk space! (/var is at {{.p}}% of capacity)`, out.V{"p": percentageFull})
|
||||
exit.Message(kind, `{{.n}} is out of disk space! (/var is at {{.p}}% of capacity)`, out.V{"n": name, "p": percentageFull})
|
||||
}
|
||||
|
||||
if percentageFull >= 85 {
|
||||
out.WarnReason(reason.RsrcInsufficientDockerStorage, `Docker is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity)`, out.V{"p": percentageFull})
|
||||
out.WarnReason(kind, `{{.n}} is nearly out of disk space, which may cause deployments to fail! ({{.p}}% of capacity)`, out.V{"n": name, "p": percentageFull})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,15 @@ var (
|
|||
3. Run "minikube ssh -- docker system prune" if using the docker container runtime`,
|
||||
Issues: []int{9024},
|
||||
}
|
||||
RsrcInsufficientPodmanStorage = Kind{
|
||||
ID: "RSRC_PODMAN_STORAGE",
|
||||
ExitCode: ExInsufficientStorage,
|
||||
Advice: `Try at least one of the following to free up space on the device:
|
||||
|
||||
1. Run "sudo podman system prune" to remove unused podman data
|
||||
2. Run "minikube ssh -- docker system prune" if using the docker container runtime`,
|
||||
Issues: []int{9024},
|
||||
}
|
||||
|
||||
RsrcInsufficientStorage = Kind{ID: "RSRC_INSUFFICIENT_STORAGE", ExitCode: ExInsufficientStorage, Style: style.UnmetRequirement}
|
||||
|
||||
|
|
|
@ -496,11 +496,11 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
}
|
||||
|
||||
t.Run("cache", func(t *testing.T) {
|
||||
t.Run("add", func(t *testing.T) {
|
||||
for _, img := range []string{"busybox:latest", "busybox:1.28.4-glibc", "k8s.gcr.io/pause:latest"} {
|
||||
t.Run("add_remote", func(t *testing.T) {
|
||||
for _, img := range []string{"k8s.gcr.io/pause:3.0", "k8s.gcr.io/pause:3.3", "k8s.gcr.io/pause:latest"} {
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img))
|
||||
if err != nil {
|
||||
t.Errorf("failed to cache add image %q. args %q err %v", img, rr.Command(), err)
|
||||
t.Errorf("failed to 'cache add' remote image %q. args %q err %v", img, rr.Command(), err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -514,7 +514,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
message := []byte("FROM scratch\nADD Dockerfile /x")
|
||||
err = ioutil.WriteFile(filepath.Join(dname, "Dockerfile"), message, 0644)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to writefile: %v", err)
|
||||
t.Fatalf("unable to write Dockerfile: %v", err)
|
||||
}
|
||||
|
||||
img := "minikube-local-cache-test:" + profile
|
||||
|
@ -525,14 +525,14 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "add", img))
|
||||
if err != nil {
|
||||
t.Errorf("failed to add local image %q. args %q err %v", img, rr.Command(), err)
|
||||
t.Errorf("failed to 'cache add' local image %q. args %q err %v", img, rr.Command(), err)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("delete_busybox:1.28.4-glibc", func(t *testing.T) {
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "delete", "busybox:1.28.4-glibc"))
|
||||
t.Run("delete_k8s.gcr.io/pause:3.3", func(t *testing.T) {
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "delete", "k8s.gcr.io/pause:3.3"))
|
||||
if err != nil {
|
||||
t.Errorf("failed to delete image busybox:1.28.4-glibc from cache. args %q: %v", rr.Command(), err)
|
||||
t.Errorf("failed to delete image k8s.gcr.io/pause:3.3 from cache. args %q: %v", rr.Command(), err)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -542,10 +542,10 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
t.Errorf("failed to do cache list. args %q: %v", rr.Command(), err)
|
||||
}
|
||||
if !strings.Contains(rr.Output(), "k8s.gcr.io/pause") {
|
||||
t.Errorf("expected 'cache list' output to include 'k8s.gcr.io/pause' but got:\n ***%s***", rr.Output())
|
||||
t.Errorf("expected 'cache list' output to include 'k8s.gcr.io/pause' but got: ***%s***", rr.Output())
|
||||
}
|
||||
if strings.Contains(rr.Output(), "busybox:1.28.4-glibc") {
|
||||
t.Errorf("expected 'cache list' output not to include busybox:1.28.4-glibc but got:\n ***%s***", rr.Output())
|
||||
if strings.Contains(rr.Output(), "k8s.gcr.io/pause:3.3") {
|
||||
t.Errorf("expected 'cache list' output not to include k8s.gcr.io/pause:3.3 but got: ***%s***", rr.Output())
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -554,24 +554,24 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
if err != nil {
|
||||
t.Errorf("failed to get images by %q ssh %v", rr.Command(), err)
|
||||
}
|
||||
if !strings.Contains(rr.Output(), "1.28.4-glibc") {
|
||||
t.Errorf("expected '1.28.4-glibc' to be in the output but got *%s*", rr.Output())
|
||||
if !strings.Contains(rr.Output(), "0184c1613d929") {
|
||||
t.Errorf("expected sha for pause:3.3 '0184c1613d929' to be in the output but got *%s*", rr.Output())
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
t.Run("cache_reload", func(t *testing.T) { // deleting image inside minikube node manually and expecting reload to bring it back
|
||||
img := "busybox:latest"
|
||||
img := "k8s.gcr.io/pause:latest"
|
||||
// deleting image inside minikube node manually
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "docker", "rmi", img))
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("failed to delete inside the node %q : %v", rr.Command(), err)
|
||||
t.Errorf("failed to manually delete image %q : %v", rr.Command(), err)
|
||||
}
|
||||
// make sure the image is deleted.
|
||||
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "sudo", "crictl", "inspecti", img))
|
||||
if err == nil {
|
||||
t.Errorf("expected an error. because image should not exist. but got *nil error* ! cmd: %q", rr.Command())
|
||||
t.Errorf("expected an error but got no error. image should not exist. ! cmd: %q", rr.Command())
|
||||
}
|
||||
// minikube cache reload.
|
||||
rr, err = Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "cache", "reload"))
|
||||
|
@ -587,7 +587,7 @@ func validateCacheCmd(ctx context.Context, t *testing.T, profile string) {
|
|||
|
||||
// delete will clean up the cached images since they are global and all other tests will load it for no reason
|
||||
t.Run("delete", func(t *testing.T) {
|
||||
for _, img := range []string{"busybox:latest", "k8s.gcr.io/pause:latest"} {
|
||||
for _, img := range []string{"k8s.gcr.io/pause:3.0", "k8s.gcr.io/pause:latest"} {
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), "cache", "delete", img))
|
||||
if err != nil {
|
||||
t.Errorf("failed to delete %s from cache. args %q: %v", img, rr.Command(), err)
|
||||
|
|
Loading…
Reference in New Issue