From 747a486b4aac2ebbbb28bd713b9a4a929f89353b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 2 Mar 2016 14:35:17 +0100 Subject: [PATCH 1/2] Add KernelMemory to "info" and show warning This change adds "KernelMemory" to the /info endpoint and shows a warning if KernelMemory is not supported by the kernel. This makes it more consistent with the other memory-limit options. Signed-off-by: Sebastiaan van Stijn --- api/client/info.go | 3 +++ daemon/info.go | 1 + docs/reference/api/docker_remote_api.md | 1 + docs/reference/api/docker_remote_api_v1.23.md | 1 + 4 files changed, 6 insertions(+) diff --git a/api/client/info.go b/api/client/info.go index 0a55f3bd52..2d02af3a58 100644 --- a/api/client/info.go +++ b/api/client/info.go @@ -105,6 +105,9 @@ func (cli *DockerCli) CmdInfo(args ...string) error { if !info.SwapLimit { fmt.Fprintln(cli.err, "WARNING: No swap limit support") } + if !info.KernelMemory { + fmt.Fprintln(cli.err, "WARNING: No kernel memory limit support") + } if !info.OomKillDisable { fmt.Fprintln(cli.err, "WARNING: No oom kill disable support") } diff --git a/daemon/info.go b/daemon/info.go index e0edc2ad22..04607fe241 100644 --- a/daemon/info.go +++ b/daemon/info.go @@ -111,6 +111,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) { if runtime.GOOS != "windows" { v.MemoryLimit = sysInfo.MemoryLimit v.SwapLimit = sysInfo.SwapLimit + v.KernelMemory = sysInfo.KernelMemory v.OomKillDisable = sysInfo.OomKillDisable v.CPUCfsPeriod = sysInfo.CPUCfsPeriod v.CPUCfsQuota = sysInfo.CPUCfsQuota diff --git a/docs/reference/api/docker_remote_api.md b/docs/reference/api/docker_remote_api.md index 715e8fede3..a4a07ef4b6 100644 --- a/docs/reference/api/docker_remote_api.md +++ b/docs/reference/api/docker_remote_api.md @@ -122,6 +122,7 @@ This section lists each version from latest to oldest. Each listing includes a * `POST /containers/(name)/update` now supports updating container's restart policy. * `POST /networks/create` now supports enabling ipv6 on the network by setting the `EnableIPv6` field (doing this with a label will no longer work). * `GET /info` now returns `CgroupDriver` field showing what cgroup driver the daemon is using; `cgroupfs` or `systemd`. +* `GET /info` now returns `KernelMemory` field, showing if "kernel memory limit" is supported. ### v1.22 API changes diff --git a/docs/reference/api/docker_remote_api_v1.23.md b/docs/reference/api/docker_remote_api_v1.23.md index 3617e54cff..2f4a66a0fb 100644 --- a/docs/reference/api/docker_remote_api_v1.23.md +++ b/docs/reference/api/docker_remote_api_v1.23.md @@ -2161,6 +2161,7 @@ Display system-wide information "IndexServerAddress": "https://index.docker.io/v1/", "InitPath": "/usr/bin/docker", "InitSha1": "", + "KernelMemory": true, "KernelVersion": "3.12.0-1-amd64", "Labels": [ "storage=ssd" From dd850530a96baef9f109fd2292f8c51a0836eefc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 2 Mar 2016 18:22:45 +0100 Subject: [PATCH 2/2] Vendor engine-api Signed-off-by: Sebastiaan van Stijn --- hack/vendor.sh | 2 +- .../engine-api/types/container/host_config.go | 26 +++++++++++++++++++ .../docker/engine-api/types/types.go | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/hack/vendor.sh b/hack/vendor.sh index 8e0831b4aa..da5b208609 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -24,7 +24,7 @@ clone git golang.org/x/net 47990a1ba55743e6ef1affd3a14e5bac8553615d https://gith clone git golang.org/x/sys eb2c74142fd19a79b3f237334c7384d5167b1b46 https://github.com/golang/sys.git clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3 clone git github.com/docker/go-connections v0.2.0 -clone git github.com/docker/engine-api 70d266e96080e3c3d63c55a4d8659e00ac1f7e6c +clone git github.com/docker/engine-api 7108f731dd4aeede9a259d0b1a86f0b7d94f12c2 clone git github.com/RackSec/srslog 6eb773f331e46fbba8eecb8e794e635e75fc04de clone git github.com/imdario/mergo 0.2.1 diff --git a/vendor/src/github.com/docker/engine-api/types/container/host_config.go b/vendor/src/github.com/docker/engine-api/types/container/host_config.go index 8587aa1df1..0db1962c34 100644 --- a/vendor/src/github.com/docker/engine-api/types/container/host_config.go +++ b/vendor/src/github.com/docker/engine-api/types/container/host_config.go @@ -65,6 +65,30 @@ func (n IpcMode) Container() string { return "" } +// UsernsMode represents userns mode in the container. +type UsernsMode string + +// IsHost indicates whether the container uses the host's userns. +func (n UsernsMode) IsHost() bool { + return n == "host" +} + +// IsPrivate indicates whether the container uses the a private userns. +func (n UsernsMode) IsPrivate() bool { + return !(n.IsHost()) +} + +// Valid indicates whether the userns is valid. +func (n UsernsMode) Valid() bool { + parts := strings.Split(string(n), ":") + switch mode := parts[0]; mode { + case "", "host": + default: + return false + } + return true +} + // UTSMode represents the UTS namespace of the container. type UTSMode string @@ -180,6 +204,7 @@ type Resources struct { CpusetCpus string // CpusetCpus 0-2, 0,1 CpusetMems string // CpusetMems 0-2, 0,1 Devices []DeviceMapping // List of devices to map inside the container + DiskQuota int64 // Disk limit (in bytes) KernelMemory int64 // Kernel memory limit (in bytes) Memory int64 // Memory limit (in bytes) MemoryReservation int64 // Memory soft limit (in bytes) @@ -228,6 +253,7 @@ type HostConfig struct { PublishAllPorts bool // Should docker publish all exposed port for the container ReadonlyRootfs bool // Is the container root filesystem in read-only SecurityOpt []string // List of string values to customize labels for MLS systems, such as SELinux. + StorageOpt []string // Storage driver options per container. Tmpfs map[string]string `json:",omitempty"` // List of tmpfs (mounts) used for the container UTSMode UTSMode // UTS namespace to use for the container ShmSize int64 // Total shm memory usage diff --git a/vendor/src/github.com/docker/engine-api/types/types.go b/vendor/src/github.com/docker/engine-api/types/types.go index 15228db53a..264624047d 100644 --- a/vendor/src/github.com/docker/engine-api/types/types.go +++ b/vendor/src/github.com/docker/engine-api/types/types.go @@ -204,6 +204,7 @@ type Info struct { Plugins PluginsInfo MemoryLimit bool SwapLimit bool + KernelMemory bool CPUCfsPeriod bool `json:"CpuCfsPeriod"` CPUCfsQuota bool `json:"CpuCfsQuota"` CPUShares bool