From 32d5f463d28460d8cc351d6f33ca9e0d1cbfe63e Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Wed, 17 Jun 2015 12:51:11 -0700 Subject: [PATCH] Add a sanity check to memory limit for /docker-daemon, and allocate at least 150Mi at least. --- pkg/kubelet/container_manager_linux.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/container_manager_linux.go b/pkg/kubelet/container_manager_linux.go index fef0bcb28cd..362227db4a7 100644 --- a/pkg/kubelet/container_manager_linux.go +++ b/pkg/kubelet/container_manager_linux.go @@ -42,6 +42,8 @@ const ( // docker memory resource container's hardlimit to workaround docker memory // leakage issue. Please see kubernetes/issues/9881 for more detail. DockerMemoryLimitThresholdPercent = 70 + // The minimum memory limit allocated to docker container: 150Mi + MinDockerMemoryLimit = 150 * 1024 * 1024 ) // A non-user container tracked by the Kubelet. @@ -90,7 +92,12 @@ func newContainerManager(cadvisorInterface cadvisor.Interface, dockerDaemonConta capacity = CapacityFromMachineInfo(info) } memoryLimit := (int64(capacity.Memory().Value() * DockerMemoryLimitThresholdPercent / 100)) - glog.Infof("Configure resource-only container %s with memory limit: %d", dockerDaemonContainerName, memoryLimit) + if memoryLimit < MinDockerMemoryLimit { + glog.Warningf("Memory limit %d for container %s is too small, reset it to %d", memoryLimit, dockerDaemonContainerName, MinDockerMemoryLimit) + memoryLimit = MinDockerMemoryLimit + } + + glog.V(2).Infof("Configure resource-only container %s with memory limit: %d", dockerDaemonContainerName, memoryLimit) dockerContainer := &fs.Manager{ Cgroups: &configs.Cgroup{