Merge pull request #73 from mrunalp/sysctl

Adds Sysctl support
This commit is contained in:
Michael Crosby
2015-07-07 09:33:44 -07:00
8 changed files with 18 additions and 16 deletions
+1 -1
View File
@@ -48,7 +48,7 @@
},
{
"ImportPath": "github.com/opencontainers/specs",
"Rev": "89fbfc172945b685f28205bdd1bef2b738bc0b62"
"Rev": "8fa5eb040abe89f09767c1b249b10757bb431cc2"
},
{
"ImportPath": "github.com/syndtr/gocapability/capability",
+6 -7
View File
@@ -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.
+1 -1
View File
@@ -1,7 +1,7 @@
# Configuration file
The containers 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.
+4 -2
View File
@@ -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 {
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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",
}
+1 -1
View File
@@ -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
}
+1
View File
@@ -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
}