From d61480ea3d31a24e5b738694b92f320479267b08 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 6 Jul 2015 19:16:55 -0400 Subject: [PATCH 1/2] Update github.com/opencontainer/specs to include Sysctl change Signed-off-by: Mrunal Patel --- Godeps/Godeps.json | 2 +- .../src/github.com/opencontainers/specs/bundle.md | 13 ++++++------- .../src/github.com/opencontainers/specs/config.md | 2 +- .../github.com/opencontainers/specs/spec_linux.go | 6 ++++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 30514da31..10f817028 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -48,7 +48,7 @@ }, { "ImportPath": "github.com/opencontainers/specs", - "Rev": "89fbfc172945b685f28205bdd1bef2b738bc0b62" + "Rev": "8fa5eb040abe89f09767c1b249b10757bb431cc2" }, { "ImportPath": "github.com/syndtr/gocapability/capability", diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/bundle.md b/Godeps/_workspace/src/github.com/opencontainers/specs/bundle.md index 897ad4db6..1948e4869 100644 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/bundle.md +++ b/Godeps/_workspace/src/github.com/opencontainers/specs/bundle.md @@ -12,20 +12,19 @@ A standard container bundle is made of the following 3 parts: # Directory layout -A Standard Container bundle is a directory containing all the content needed to load and run a container. This includes its configuration file, content directories, and cryptographic signatures. The main property of this directory layout is that it can be moved as a unit to another machine and run the same container. +A Standard Container bundle is a directory containing all the content needed to load and run a container. This includes its configuration file (`config.json`) and content directories. The main property of this directory layout is that it can be moved as a unit to another machine and run the same container. -One or more *content directories* may be adjacent to the configuration file. This at least includes the root filesystem (referenced in the configuration by the *rootfs* field) and other related content (signatures, other configs, etc.). The interpretation of these resources is specified in the configuration. +The syntax and semantics for `config.json` are described in [this specification](config.md). + +One or more *content directories* may be adjacent to the configuration file. This must include at least the root filesystem (referenced in the configuration file by the *root* field) and may include other related content (signatures, other configs, etc.). The interpretation of these resources is specified in the configuration. The names of the directories may be arbitrary, but users should consider using conventional names as in the example below. ``` / ! -- config.json ! ---- rootfs1 +--- rootfs ! ---- rootfs2 +--- signatures ``` -The syntax and semantics for config.json are described in this specification. - -One or more content directories can be specified as root file systems for containers. They COULD be called rootfs..10^100 but SHALL be called whatever you want. diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/config.md b/Godeps/_workspace/src/github.com/opencontainers/specs/config.md index 9fc1b4302..4d9117c7c 100644 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/config.md +++ b/Godeps/_workspace/src/github.com/opencontainers/specs/config.md @@ -1,7 +1,7 @@ # Configuration file The container’s top-level directory MUST contain a configuration file called `config.json`. -For now the schema is defined in [spec.go](https://github.com/opencontainers/runc/blob/master/spec.go) and [spec_linux.go](https://github.com/opencontainers/runc/blob/master/spec_linux.go), this will be moved to a JSON schema overtime. +For now the canonical schema is defined in [spec.go](spec.go) and [spec_linux.go](spec_linux.go), but this will be moved to a formal JSON schema over time. The configuration file contains metadata necessary to implement standard operations against the container. This includes the process to run, environment variables to inject, sandboxing features to use, etc. diff --git a/Godeps/_workspace/src/github.com/opencontainers/specs/spec_linux.go b/Godeps/_workspace/src/github.com/opencontainers/specs/spec_linux.go index 207f5c885..c272f6501 100644 --- a/Godeps/_workspace/src/github.com/opencontainers/specs/spec_linux.go +++ b/Godeps/_workspace/src/github.com/opencontainers/specs/spec_linux.go @@ -17,8 +17,8 @@ type Linux struct { GidMappings []IDMapping `json:"gidMappings"` // Rlimits specifies rlimit options to apply to the container's process. Rlimits []Rlimit `json:"rlimits"` - // SystemProperties are a set of key value pairs that are set for the container on start. - SystemProperties map[string]string `json:"systemProperties"` + // Sysctl are a set of key value pairs that are set for the container on start. + Sysctl map[string]string `json:"sysctl"` // Resources contain cgroup information for handling resource constraints // for the container. Resources Resources `json:"resources"` @@ -106,6 +106,8 @@ type Memory struct { Swap int64 `json:"swap"` // Kernel memory limit (in bytes) Kernel int64 `json:"kernel"` + // How aggressive the kernel will swap memory pages. Range from 0 to 100. Set -1 to use system default. + Swappiness int64 `json:"swappiness"` } type CPU struct { From 8ea6c65d12c27d484b2bcc417c3c5c42e2c159dd Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 6 Jul 2015 19:18:08 -0400 Subject: [PATCH 2/2] Rename SystemProperties to Sysctl and make it available in the runc config Signed-off-by: Mrunal Patel --- libcontainer/configs/config.go | 4 ++-- libcontainer/integration/exec_test.go | 4 ++-- libcontainer/standard_init_linux.go | 2 +- spec.go | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libcontainer/configs/config.go b/libcontainer/configs/config.go index 04ea91ffd..83381c84c 100644 --- a/libcontainer/configs/config.go +++ b/libcontainer/configs/config.go @@ -135,9 +135,9 @@ type Config struct { // so that these files prevent any writes. ReadonlyPaths []string `json:"readonly_paths"` - // SystemProperties is a map of properties and their values. It is the equivalent of using + // Sysctl is a map of properties and their values. It is the equivalent of using // sysctl -w my.property.name value in Linux. - SystemProperties map[string]string `json:"system_properties"` + Sysctl map[string]string `json:"sysctl"` // Seccomp allows actions to be taken whenever a syscall is made within the container. // By default, all syscalls are allowed with actions to allow, trap, kill, or return an errno diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index c14c659f1..881186386 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -753,7 +753,7 @@ func TestMountCmds(t *testing.T) { } } -func TestSystemProperties(t *testing.T) { +func TestSysctl(t *testing.T) { if testing.Short() { return } @@ -766,7 +766,7 @@ func TestSystemProperties(t *testing.T) { defer remove(rootfs) config := newTemplateConfig(rootfs) - config.SystemProperties = map[string]string{ + config.Sysctl = map[string]string{ "kernel.shmmni": "8192", } diff --git a/libcontainer/standard_init_linux.go b/libcontainer/standard_init_linux.go index 74a322934..b399aa5d1 100644 --- a/libcontainer/standard_init_linux.go +++ b/libcontainer/standard_init_linux.go @@ -65,7 +65,7 @@ func (l *linuxStandardInit) Init() error { return err } - for key, value := range l.config.Config.SystemProperties { + for key, value := range l.config.Config.Sysctl { if err := writeSystemProperty(key, value); err != nil { return err } diff --git a/spec.go b/spec.go index 4a31f02d1..ec36cfbcf 100644 --- a/spec.go +++ b/spec.go @@ -211,6 +211,7 @@ func createLibcontainerConfig(spec *specs.LinuxSpec) (*configs.Config, error) { "/proc/sys", "/proc/sysrq-trigger", "/proc/irq", "/proc/bus", } } + config.Sysctl = spec.Linux.Sysctl return config, nil }