Skip to content

Commit

Permalink
config-linux: Move 'disableOOMKiller' under 'memory'
Browse files Browse the repository at this point in the history
It's backed by memory.oom_control, so this commit moves it in with
the rest of the memory-controller config.

Looking at the history, the initial request landing a setting for this
in the Docker/OCI ecosystem seems to be [1], which added
Cgroup.OomKillDisable.  That commit was carried from libcontainer into
runC [2] where it is now Resources.OomKillDisable [3].  From runC it
was carried into this repo (with some renaming) in [4].  Subsequent
early doc updates landed in [5,6].  In none of those can I find
discussion about why the setting is not already under memory.  I
expect the reason is that the runC structures are flat, so "under
memory" is not a thing there.  But in this spec, resources has
per-controller sub-properties.  The fact that disableOOMKiller
belonged to the memory controller may have been overlooked in [4] and
never revisited until now.

[1]: docker-archive/libcontainer#417
     Subject: cgroups: add support for oom control
[2]: opencontainers/runc@295c708
     Subject: cgroups: add support for oom control
[3]: https://github.com/opencontainers/runc/blob/v1.0.0-rc3/libcontainer/configs/cgroup_unix.go#L113-L114
[4]: #51
     Subject: Add Go types for specification
[5]: #137
     Subject: Adding cgroups path to the Spec.
[6]: #199
     Subject: runtime: config: linux: add cgroups informations

Signed-off-by: W. Trevor King <[email protected]>
  • Loading branch information
wking committed Jul 12, 2017
1 parent 06c488c commit ef51409
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 29 deletions.
26 changes: 8 additions & 18 deletions config-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,6 @@ Each entry has the following structure:
]
```

### <a name="configLinuxDisableOutOfMemoryKiller" />Disable out-of-memory killer

`disableOOMKiller` contains a boolean (`true` or `false`) that enables or disables the Out of Memory killer for a cgroup.
If enabled (`false`), tasks that attempt to consume more memory than they are allowed are immediately killed by the OOM killer.
The OOM killer is enabled by default in every cgroup using the `memory` subsystem.
To disable it, specify a value of `true`.
For more information, see the kernel cgroups documentation about [memory][cgroup-v1-memory].

* **`disableOOMKiller`** *(bool, OPTIONAL)* - enables or disables the OOM killer

#### Example

```json
"disableOOMKiller": false
```

### <a name="configLinuxMemory" />Memory

**`memory`** (object, OPTIONAL) represents the cgroup subsystem `memory` and it's used to set limits on the container's memory usage.
Expand All @@ -282,9 +266,14 @@ Values for memory specify the limit in bytes, or `-1` for unlimited memory.
* **`kernel`** *(int64, OPTIONAL)* - sets hard limit for kernel memory
* **`kernelTCP`** *(int64, OPTIONAL)* - sets hard limit for kernel TCP buffer memory

For `swappiness` the values are from 0 to 100. Higher means more swappy.
The following properties do not specify memory limits, but are covered by the `memory` controller:

* **`swappiness`** *(uint64, OPTIONAL)* - sets swappiness parameter of vmscan (See sysctl's vm.swappiness)
The values are from 0 to 100. Higher means more swappy.
* **`disableOOMKiller`** *(bool, OPTIONAL)* - enables or disables the OOM killer.
If enabled (`false`), tasks that attempt to consume more memory than they are allowed are immediately killed by the OOM killer.
The OOM killer is enabled by default in every cgroup using the `memory` subsystem.
To disable it, specify a value of `true`.

#### Example

Expand All @@ -295,7 +284,8 @@ For `swappiness` the values are from 0 to 100. Higher means more swappy.
"swap": 536870912,
"kernel": -1,
"kernelTCP": -1,
"swappiness": 0
"swappiness": 0,
"disableOOMKiller": false
}
```

Expand Down
6 changes: 3 additions & 3 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ For Linux-based systems, the `process` object supports the following process-spe
If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value.
If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`.

This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#disable-out-of-memory-killer) is scoped for a memory cgroup.
This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#memory) is scoped for a memory cgroup.
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label for the process.
For more information about SELinux, see [SELinux documentation][selinux].
Expand Down Expand Up @@ -710,7 +710,8 @@ Here is a full example `config.json` for reference.
"swap": 536870912,
"kernel": -1,
"kernelTCP": -1,
"swappiness": 0
"swappiness": 0,
"disableOOMKiller": false
},
"cpu": {
"shares": 1024,
Expand All @@ -721,7 +722,6 @@ Here is a full example `config.json` for reference.
"cpus": "2-3",
"mems": "0-7"
},
"disableOOMKiller": false,
"devices": [
{
"allow": false,
Expand Down
8 changes: 4 additions & 4 deletions schema/config-linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@
}
}
},
"disableOOMKiller": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/disableOOMKiller",
"type": "boolean"
},
"hugepageLimits": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/hugepageLimits",
"type": "array",
Expand Down Expand Up @@ -193,6 +189,10 @@
"swappiness": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/swappiness",
"$ref": "defs.json#/definitions/uint64"
},
"disableOOMKiller": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/memory/disableOOMKiller",
"type": "boolean"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions schema/test/config/good/spec-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@
"swap": 536870912,
"kernel": -1,
"kernelTCP": -1,
"swappiness": 0
"swappiness": 0,
"disableOOMKiller": false
},
"cpu": {
"shares": 1024,
Expand All @@ -252,7 +253,6 @@
"cpus": "2-3",
"mems": "0-7"
},
"disableOOMKiller": false,
"devices": [
{
"allow": false,
Expand Down
4 changes: 2 additions & 2 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ type LinuxMemory struct {
KernelTCP *int64 `json:"kernelTCP,omitempty"`
// How aggressive the kernel will swap memory pages.
Swappiness *uint64 `json:"swappiness,omitempty"`
// DisableOOMKiller disables the OOM killer for out of memory conditions
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
}

// LinuxCPU for Linux cgroup 'cpu' resource management
Expand Down Expand Up @@ -322,8 +324,6 @@ type LinuxNetwork struct {
type LinuxResources struct {
// Devices configures the device whitelist.
Devices []LinuxDeviceCgroup `json:"devices,omitempty"`
// DisableOOMKiller disables the OOM killer for out of memory conditions
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
// Memory restriction configuration
Memory *LinuxMemory `json:"memory,omitempty"`
// CPU resource restriction configuration
Expand Down

0 comments on commit ef51409

Please sign in to comment.