Skip to content

Commit 99a1b8d

Browse files
committed
config: Shift oomScoreAdj from linux.resources to process
The only discussion related to this is in [1,2], where the relationship between oomScoreAdj and disableOOMKiller is raised. But since 429f936 (Adding cgroups path to the Spec, 2015-09-02, #137) resources has been tied to cgroups, and oomScoreAdj is not about cgroups. For example, we currently have (in config-linux.md): You can configure a container's cgroups via the resources field of the Linux configuration. I suggested we move the property from linux.resources.oomScoreAdj to linux.oomScoreAdj so config authors and runtimes don't have to worry about what cgroupsPath means if the only entry in resources is oomScoreAdj. Michael responded with [4]: If anything it should probably go on the process So that's what this commit does. [1]: #236 [2]: #292 [3]: #137 [4]: #782 (comment) Signed-off-by: W. Trevor King <[email protected]>
1 parent 101e6f9 commit 99a1b8d

5 files changed

Lines changed: 13 additions & 22 deletions

File tree

config-linux.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -263,21 +263,6 @@ For more information, see [the memory cgroup man page][cgroup-v1-memory].
263263
"disableOOMKiller": false
264264
```
265265

266-
#### <a name="configLinuxSetOomScoreAdj" />Set oom_score_adj
267-
268-
`oomScoreAdj` sets heuristic regarding how the process is evaluated by the kernel during memory pressure.
269-
For more information, see [the proc filesystem documentation section 3.1][procfs].
270-
This is a kernel/system level setting, where as `disableOOMKiller` is scoped for a memory cgroup.
271-
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory].
272-
273-
* **`oomScoreAdj`** *(int, OPTIONAL)* - adjust the oom-killer score
274-
275-
###### Example
276-
277-
```json
278-
"oomScoreAdj": 100
279-
```
280-
281266
#### <a name="configLinuxMemory" />Memory
282267

283268
**`memory`** (object, OPTIONAL) represents the cgroup subsystem `memory` and it's used to set limits on the container's memory usage.

config.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ For Linux-based systems the process structure supports the following process spe
155155

156156
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile to be applied to processes in the container.
157157
For more information about AppArmor, see [AppArmor documentation][apparmor].
158+
* **`oomScoreAdj`** (int, OPTIONAL) specifies an adjustment for evaluating the process under memory pressure.
159+
For more information, see [the proc filesystem documentation section 3.1][procfs_2].
160+
This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#disable-out-of-memory-killer) is scoped for a memory cgroup.
161+
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
158162
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label to be applied to the processes in the container.
159163
For more information about SELinux, see [SELinux documentation][selinux].
160164

@@ -503,6 +507,7 @@ Here is a full example `config.json` for reference.
503507
}
504508
],
505509
"apparmorProfile": "acme_secure_profile",
510+
"oomScoreAdj": 100,
506511
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
507512
"noNewPrivileges": true
508513
},
@@ -682,7 +687,6 @@ Here is a full example `config.json` for reference.
682687
"limit": 9223372036854772000
683688
}
684689
],
685-
"oomScoreAdj": 100,
686690
"memory": {
687691
"limit": 536870912,
688692
"reservation": 536870912,
@@ -818,8 +822,10 @@ Here is a full example `config.json` for reference.
818822

819823

820824
[apparmor]: https://wiki.ubuntu.com/AppArmor
825+
[cgroup-v1-memory_2]: https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
821826
[selinux]:http://selinuxproject.org/page/Main_Page
822827
[no-new-privs]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
828+
[procfs_2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
823829
[semver-v2.0.0]: http://semver.org/spec/v2.0.0.html
824830
[go-environment]: https://golang.org/doc/install/source#environment
825831
[ieee-1003.1-2001-xbd-c8.1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_01

schema/config-linux.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@
4747
"$ref": "defs-linux.json#/definitions/DeviceCgroup"
4848
}
4949
},
50-
"oomScoreAdj": {
51-
"id": "https://opencontainers.org/schema/bundle/linux/resources/oomScoreAdj",
52-
"type": "integer",
53-
},
5450
"pids": {
5551
"id": "https://opencontainers.org/schema/bundle/linux/resources/pids",
5652
"type": "object",

schema/config-schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@
178178
"id": "https://opencontainers.org/schema/bundle/process/linux/apparmorProfile",
179179
"type": "string"
180180
},
181+
"oomScoreAdj": {
182+
"id": "https://opencontainers.org/schema/bundle/process/linux/oomScoreAdj",
183+
"type": "integer",
184+
},
181185
"selinuxLabel": {
182186
"id": "https://opencontainers.org/schema/bundle/process/linux/selinuxLabel",
183187
"type": "string"

specs-go/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ type Process struct {
5252
NoNewPrivileges bool `json:"noNewPrivileges,omitempty" platform:"linux"`
5353
// ApparmorProfile specifies the apparmor profile for the container.
5454
ApparmorProfile string `json:"apparmorProfile,omitempty" platform:"linux"`
55+
// Specify an oom_score_adj for the container.
56+
OOMScoreAdj *int `json:"oomScoreAdj,omitempty"`
5557
// SelinuxLabel specifies the selinux context that the container process is run as.
5658
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
5759
}
@@ -335,8 +337,6 @@ type LinuxResources struct {
335337
Devices []LinuxDeviceCgroup `json:"devices,omitempty"`
336338
// DisableOOMKiller disables the OOM killer for out of memory conditions
337339
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
338-
// Specify an oom_score_adj for the container.
339-
OOMScoreAdj *int `json:"oomScoreAdj,omitempty"`
340340
// Memory restriction configuration
341341
Memory *LinuxMemory `json:"memory,omitempty"`
342342
// CPU resource restriction configuration

0 commit comments

Comments
 (0)