From 630116b2c045ca9ab5b8fd878bfb00db3590e4ab Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Thu, 18 Apr 2013 21:08:20 -0700 Subject: [PATCH] Remove the NO_MEMORY_LIMIT constant Upstream-commit: f68d107a1368b3d4f3342456a2b0675659688354 Component: engine --- components/engine/Makefile | 5 +---- components/engine/commands.go | 3 +-- components/engine/container.go | 9 +++++++-- components/engine/docker/docker.go | 7 +------ components/engine/runtime_test.go | 2 -- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/components/engine/Makefile b/components/engine/Makefile index c89f0f33b0..a6eb613830 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -13,10 +13,7 @@ endif GIT_COMMIT = $(shell git rev-parse --short HEAD) GIT_STATUS = $(shell test -n "`git status --porcelain`" && echo "+CHANGES") -NO_MEMORY_LIMIT ?= 0 -export NO_MEMORY_LIMIT - -BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS) -X main.NO_MEMORY_LIMIT $(NO_MEMORY_LIMIT)" +BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT $(GIT_COMMIT)$(GIT_STATUS)" SRC_DIR := $(GOPATH)/src diff --git a/components/engine/commands.go b/components/engine/commands.go index 6ab164d647..274acf4992 100644 --- a/components/engine/commands.go +++ b/components/engine/commands.go @@ -21,8 +21,7 @@ import ( const VERSION = "0.1.6" var ( - GIT_COMMIT string - NO_MEMORY_LIMIT bool + GIT_COMMIT string ) func (srv *Server) Name() string { diff --git a/components/engine/container.go b/components/engine/container.go index 0d3427d9c0..c23578875d 100644 --- a/components/engine/container.go +++ b/components/engine/container.go @@ -373,10 +373,15 @@ func (container *Container) Start() error { return err } - if container.Config.Memory > 0 && NO_MEMORY_LIMIT { - log.Printf("WARNING: This version of docker has been compiled without memory limit support. Discarding the limit.") + // Make sure the config is compatible with the current kernel + if container.Config.Memory > 0 && !container.runtime.capabilities.MemoryLimit { + log.Printf("WARNING: Your kernel does not support memory limit capabilities. Limitation discarded.\n") container.Config.Memory = 0 } + if container.Config.Memory > 0 && !container.runtime.capabilities.SwapLimit { + log.Printf("WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n") + container.Config.MemorySwap = -1 + } if err := container.generateLXCConfig(); err != nil { return err diff --git a/components/engine/docker/docker.go b/components/engine/docker/docker.go index 83c47c6f1e..411e4d0c96 100644 --- a/components/engine/docker/docker.go +++ b/components/engine/docker/docker.go @@ -14,8 +14,7 @@ import ( ) var ( - GIT_COMMIT string - NO_MEMORY_LIMIT string + GIT_COMMIT string ) func main() { @@ -39,15 +38,11 @@ func main() { os.Setenv("DEBUG", "1") } docker.GIT_COMMIT = GIT_COMMIT - docker.NO_MEMORY_LIMIT = NO_MEMORY_LIMIT == "1" if *flDaemon { if flag.NArg() != 0 { flag.Usage() return } - if NO_MEMORY_LIMIT == "1" { - log.Printf("WARNING: This version of docker has been compiled without memory limit support.") - } if err := daemon(*pidfile); err != nil { log.Fatal(err) } diff --git a/components/engine/runtime_test.go b/components/engine/runtime_test.go index 20e7ee140d..48786fd5be 100644 --- a/components/engine/runtime_test.go +++ b/components/engine/runtime_test.go @@ -46,8 +46,6 @@ func layerArchive(tarfile string) (io.Reader, error) { } func init() { - NO_MEMORY_LIMIT = os.Getenv("NO_MEMORY_LIMIT") == "1" - // Hack to run sys init during unit testing if SelfPath() == "/sbin/init" { SysInit()