Skip to content

Commit 2e968a8

Browse files
committed
libct/cg/sd/v2: "support" (ignore) memory.oom.group
Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent c013be5 commit 2e968a8

File tree

1 file changed

+27
-0
lines changed
  • libcontainer/cgroups/systemd

1 file changed

+27
-0
lines changed

libcontainer/cgroups/systemd/v2.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ func unifiedResToSystemdProps(conn *systemdDbus.Conn, res map[string]string) (pr
105105
props = append(props,
106106
newProp(m[k], bits))
107107

108+
case "memory.high", "memory.low", "memory.min", "memory.max", "memory.swap.max":
109+
num := uint64(math.MaxUint64)
110+
if v != "max" {
111+
num, err = strconv.ParseUint(v, 10, 64)
112+
if err != nil {
113+
return nil, fmt.Errorf("unified resource %q value conversion error: %w", k, err)
114+
}
115+
}
116+
m := map[string]string{
117+
"memory.high": "MemoryHigh",
118+
"memory.low": "MemoryLow",
119+
"memory.min": "MemoryMin",
120+
"memory.max": "MemoryMax",
121+
"memory.swap.max": "MemorySwapMax",
122+
}
123+
props = append(props,
124+
newProp(m[k], num))
125+
108126
case "pids.max":
109127
num := uint64(math.MaxUint64)
110128
if v != "max" {
@@ -118,6 +136,15 @@ func unifiedResToSystemdProps(conn *systemdDbus.Conn, res map[string]string) (pr
118136
newProp("TasksAccounting", true),
119137
newProp("TasksMax", num))
120138

139+
case "memory.oom.group":
140+
// Setting this to 1 is roughly equivalent to OOMPolicy=kill
141+
// (as per systemd.service(5) and
142+
// https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html),
143+
// but it's not clear what to do if it is unset or set
144+
// to 0 in runc update, as there are two other possible
145+
// values for OOMPolicy (continue/stop).
146+
fallthrough
147+
121148
default:
122149
// Ignore the unknown resource here -- will still be
123150
// applied in Set which calls fs2.Set.

0 commit comments

Comments
 (0)