From 44b93f4776891a703f29b309f80ff9a18765b051 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Fri, 21 Aug 2020 09:49:48 -0400 Subject: [PATCH] Change MemoryCapacity to StorageCapacity to be more accurate --- cmd/minikube/cmd/status.go | 2 +- cmd/minikube/cmd/test | 14 -------------- pkg/minikube/constants/constants.go | 4 ++-- pkg/minikube/machine/start.go | 8 ++++---- test/integration/status_test.go | 4 ++-- 5 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 cmd/minikube/cmd/test diff --git a/cmd/minikube/cmd/status.go b/cmd/minikube/cmd/status.go index ed849a0a0ac9..fc931be6df85 100644 --- a/cmd/minikube/cmd/status.go +++ b/cmd/minikube/cmd/status.go @@ -322,7 +322,7 @@ func nodeStatus(api libmachine.API, cc config.ClusterConfig, n config.Node) (*St } // Check storage - p, err := machine.MemoryCapacity(cr, "/var") + p, err := machine.StorageCapacity(cr, "/var") if err != nil { glog.Errorf("failed to get memory capacity of /var: %v", err) st.Host = state.Error.String() diff --git a/cmd/minikube/cmd/test b/cmd/minikube/cmd/test deleted file mode 100644 index 2e8a767c400e..000000000000 --- a/cmd/minikube/cmd/test +++ /dev/null @@ -1,14 +0,0 @@ -{"data":{"currentstep":"0","message":"[insufficient-storage-20200820141526-290506] minikube v1.12.3 on Debian 9.13\n","name":"Initial Minikube Setup","totalsteps":"12"},"datacontenttype":"application/json","id":"3eb59878-f133-442e-9b72-6d732f3352e2","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.step"} -{"data":{"message":"KUBECONFIG=/home/jenkins/minikube-integration/linux-amd64-docker-9034-287957-2c74cf22f910c2fc2ef59a5e206db9f3d3d72b82/kubeconfig\n"},"datacontenttype":"application/json","id":"a6150a88-f9db-41b9-8d21-e9f1504e2098","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.info"} -{"data":{"message":"MINIKUBE_BIN=out/minikube-linux-amd64\n"},"datacontenttype":"application/json","id":"8453e611-1d14-4431-bd19-6692b144498b","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.info"} -{"data":{"message":"MINIKUBE_HOME=/home/jenkins/minikube-integration/linux-amd64-docker-9034-287957-2c74cf22f910c2fc2ef59a5e206db9f3d3d72b82/.minikube\n"},"datacontenttype":"application/json","id":"0e2b6d5d-197a-4dd3-9505-dd81d151d5f0","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.info"} -{"data":{"message":"MINIKUBE_LOCATION=9034\n"},"datacontenttype":"application/json","id":"db23721d-481c-4500-9765-5a0229227b68","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.info"} -{"data":{"message":"MINIKUBE_TEST_MEMORY_CAPACITY=100\n"},"datacontenttype":"application/json","id":"9dd5de29-0153-4113-acf7-d7969bdafbbe","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.info"} -{"data":{"currentstep":"1","message":"Using the docker driver based on user configuration\n","name":"Selecting Driver","totalsteps":"12"},"datacontenttype":"application/json","id":"46709583-0f6a-4987-adc8-b5692148998b","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.step"} -{"data":{"message":"\n"},"datacontenttype":"application/json","id":"3c38872d-eb51-489d-adf7-4b0db614587c","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.error"} -{"data":{"message":"'docker' driver reported a issue that could affect the performance.\n"},"datacontenttype":"application/json","id":"555e511f-a750-41ab-8886-d231c859ed81","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.warning"} -{"data":{"message":"Suggestion: enable overlayfs kernel module on your Linux\n"},"datacontenttype":"application/json","id":"c9e6237c-cd54-4d7c-888d-1839304c3af0","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.error"} -{"data":{"message":"\n"},"datacontenttype":"application/json","id":"2024d4e9-4c93-4dc9-a050-971ada6dfc8a","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.error"} -{"data":{"currentstep":"3","message":"Starting control plane node insufficient-storage-20200820141526-290506 in cluster insufficient-storage-20200820141526-290506\n","name":"Starting Node","totalsteps":"12"},"datacontenttype":"application/json","id":"9a6c0793-4eea-4002-aa81-b28a111b4e9c","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.step"} -{"data":{"currentstep":"6","message":"Creating docker container (CPUs=2, Memory=7500MB) ...\n","name":"Creating Container","totalsteps":"12"},"datacontenttype":"application/json","id":"3a2ad48f-d4ec-4b69-b2d2-f1d86f4c5cc9","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.step"} -{"data":{"exitcode":"507","message":"docker daemon out of memory. No space left on device\n"},"datacontenttype":"application/json","id":"deb577e1-e4ce-40e0-bf2c-7157a1f569ad","source":"https://minikube.sigs.k8s.io/","specversion":"1.0","type":"io.k8s.sigs.minikube.error"} \ No newline at end of file diff --git a/pkg/minikube/constants/constants.go b/pkg/minikube/constants/constants.go index a044c0c39794..199f50760d98 100644 --- a/pkg/minikube/constants/constants.go +++ b/pkg/minikube/constants/constants.go @@ -72,8 +72,8 @@ const ( MinikubeActivePodmanEnv = "MINIKUBE_ACTIVE_PODMAN" // MinikubeForceSystemdEnv is used to force systemd as cgroup manager for the container runtime MinikubeForceSystemdEnv = "MINIKUBE_FORCE_SYSTEMD" - // TestMemoryCapacityEnv is used in integration tests for insufficient storage with 'minikube status' - TestMemoryCapacityEnv = "MINIKUBE_TEST_MEMORY_CAPACITY" + // TestStorageCapacityEnv is used in integration tests for insufficient storage with 'minikube status' + TestStorageCapacityEnv = "MINIKUBE_TEST_STORAGE_CAPACITY" ) var ( diff --git a/pkg/minikube/machine/start.go b/pkg/minikube/machine/start.go index a07e29a70a0d..502b033f9850 100644 --- a/pkg/minikube/machine/start.go +++ b/pkg/minikube/machine/start.go @@ -218,7 +218,7 @@ func postStartValidations(h *host.Host, drvName string) { glog.Warningf("error getting command runner: %v", err) } // make sure /var isn't full, otherwise warn - percentageFull, err := MemoryCapacity(r, "/var") + percentageFull, err := StorageCapacity(r, "/var") if err != nil { glog.Warningf("error getting percentage of /var that is free: %v", err) } @@ -231,9 +231,9 @@ func postStartValidations(h *host.Host, drvName string) { } } -// MemoryCapacity returns the capacity of dir in the VM/container -func MemoryCapacity(cr command.Runner, dir string) (int, error) { - if s := os.Getenv(constants.TestMemoryCapacityEnv); s != "" { +// StorageCapacity returns the capacity of dir in the VM/container as a percentage +func StorageCapacity(cr command.Runner, dir string) (int, error) { + if s := os.Getenv(constants.TestStorageCapacityEnv); s != "" { return strconv.Atoi(s) } output, err := cr.RunCmd(exec.Command("sh", "-c", fmt.Sprintf("df -h %s | awk 'NR==2{print $5}'", dir))) diff --git a/test/integration/status_test.go b/test/integration/status_test.go index 3527e1266aa5..c89ed58762fa 100644 --- a/test/integration/status_test.go +++ b/test/integration/status_test.go @@ -44,7 +44,7 @@ func TestInsufficientStorage(t *testing.T) { startArgs = append(startArgs, StartArgs()...) c := exec.CommandContext(ctx, Target(), startArgs...) // artificially set /var to 100% capacity - c.Env = append(os.Environ(), fmt.Sprintf("%s=100", constants.TestMemoryCapacityEnv)) + c.Env = append(os.Environ(), fmt.Sprintf("%s=100", constants.TestStorageCapacityEnv)) rr, err := Run(t, c) if err == nil { @@ -69,7 +69,7 @@ func runStatusCmd(ctx context.Context, t *testing.T, profile string) []byte { // make sure minikube status shows insufficient storage c := exec.CommandContext(ctx, Target(), "status", "-p", profile, "--output=json", "--layout=cluster", "--alsologtostderr") // artificially set /var to 100% capacity - c.Env = append(os.Environ(), fmt.Sprintf("%s=100", constants.TestMemoryCapacityEnv)) + c.Env = append(os.Environ(), fmt.Sprintf("%s=100", constants.TestStorageCapacityEnv)) rr, err := Run(t, c) // status exits non-0 if status isn't Running if err == nil {