Skip to content

Commit 494a5a6

Browse files
authored
Merge pull request #1158 from kolyshkin/check-before-update
config-linux: add memory.checkBeforeUpdate
2 parents cbb84be + 9e658bc commit 494a5a6

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

config-linux.md

+5
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ The following properties do not specify memory limits, but are covered by the `m
336336
To disable it, specify a value of `true`.
337337
* **`useHierarchy`** *(bool, OPTIONAL)* - enables or disables hierarchical memory accounting.
338338
If enabled (`true`), child cgroups will share the memory limits of this cgroup.
339+
* **`checkBeforeUpdate`** *(bool, OPTIONAL)* - enables container memory usage check before setting a new limit.
340+
If enabled (`true`), runtime MAY check if a new memory limit is lower than the current usage, and MUST
341+
reject the new limit. Practically, when cgroup v1 is used, the kernel rejects the limit lower than the
342+
current usage, and when cgroup v2 is used, an OOM killer is invoked. This setting can be used on
343+
cgroup v2 to mimic the cgroup v1 behavior.
339344

340345
#### Example
341346

schema/config-linux.json

+3
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
},
170170
"useHierarchy": {
171171
"type": "boolean"
172+
},
173+
"checkBeforeUpdate": {
174+
"type": "boolean"
172175
}
173176
}
174177
},

schema/test/config/good/spec-example.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@
270270
"kernelTCP": -1,
271271
"swappiness": 0,
272272
"disableOOMKiller": false,
273-
"useHierarchy": false
273+
"useHierarchy": false,
274+
"checkBeforeUpdate": false
274275
},
275276
"cpu": {
276277
"shares": 1024,

specs-go/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ type LinuxMemory struct {
319319
DisableOOMKiller *bool `json:"disableOOMKiller,omitempty"`
320320
// Enables hierarchical memory accounting
321321
UseHierarchy *bool `json:"useHierarchy,omitempty"`
322+
// CheckBeforeUpdate enables checking if a new memory limit is lower
323+
// than the current usage during update, and if so, rejecting the new
324+
// limit.
325+
CheckBeforeUpdate *bool `json:"checkBeforeUpdate,omitempty"`
322326
}
323327

324328
// LinuxCPU for Linux cgroup 'cpu' resource management

0 commit comments

Comments
 (0)