Skip to content

Commit 8202372

Browse files
authored
Merge pull request #789 from wking/move-oom-adj-to-process
config: Shift oomScoreAdj from linux.resources to process
2 parents db100f4 + 4b49c64 commit 8202372

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

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`** *(int, OPTIONAL)* adjusts the oom-killer score in `[pid]/oom_score_adj` for the container process's `[pid]` in a [proc pseudo-filesystem][procfs].
269-
If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value.
270-
If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`.
271-
272-
This is a kernel/system level setting, where as `disableOOMKiller` is scoped for a memory cgroup.
273-
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory].
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ For Linux-based systems the process structure supports the following process spe
154154

155155
* **`apparmorProfile`** (string, OPTIONAL) specifies the name of the AppArmor profile to be applied to processes in the container.
156156
For more information about AppArmor, see [AppArmor documentation][apparmor].
157+
* **`oomScoreAdj`** *(int, OPTIONAL)* adjusts the oom-killer score in `[pid]/oom_score_adj` for the container process's `[pid]` in a [proc pseudo-filesystem][procfs].
158+
If `oomScoreAdj` is set, the runtime MUST set `oom_score_adj` to the given value.
159+
If `oomScoreAdj` is not set, the runtime MUST NOT change the value of `oom_score_adj`.
160+
161+
This is a per-process setting, where as [`disableOOMKiller`](config-linux.md#disable-out-of-memory-killer) is scoped for a memory cgroup.
162+
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
157163
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label to be applied to the processes in the container.
158164
For more information about SELinux, see [SELinux documentation][selinux].
159165

@@ -503,6 +509,7 @@ Here is a full example `config.json` for reference.
503509
}
504510
],
505511
"apparmorProfile": "acme_secure_profile",
512+
"oomScoreAdj": 100,
506513
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
507514
"noNewPrivileges": true
508515
},
@@ -682,7 +689,6 @@ Here is a full example `config.json` for reference.
682689
"limit": 9223372036854772000
683690
}
684691
],
685-
"oomScoreAdj": 100,
686692
"memory": {
687693
"limit": 536870912,
688694
"reservation": 536870912,
@@ -818,8 +824,10 @@ Here is a full example `config.json` for reference.
818824

819825

820826
[apparmor]: https://wiki.ubuntu.com/AppArmor
827+
[cgroup-v1-memory_2]: https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
821828
[selinux]:http://selinuxproject.org/page/Main_Page
822829
[no-new-privs]: https://www.kernel.org/doc/Documentation/prctl/no_new_privs.txt
830+
[procfs_2]: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
823831
[semver-v2.0.0]: http://semver.org/spec/v2.0.0.html
824832
[go-environment]: https://golang.org/doc/install/source#environment
825833
[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)