Skip to content

Commit 9a095e4

Browse files
committed
libct/cg/sd/v1: add SkipFreezeOnSet knob
This is helpful to kubernetes in cases it knows for sure that the freeze is not required (since it created the systemd unit with no device restrictions). As the code is trivial, no tests are required. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent fec49f2 commit 9a095e4

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

libcontainer/cgroups/systemd/v1.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ func (m *legacyManager) freezeBeforeSet(unitName string, r *configs.Resources) (
346346
// Special case for SkipDevices, as used by Kubernetes to create pod
347347
// cgroups with allow-all device policy).
348348
if r.SkipDevices {
349+
if r.SkipFreezeOnSet {
350+
// Both needsFreeze and needsThaw are false.
351+
return
352+
}
353+
349354
// No need to freeze if SkipDevices is set, and either
350355
// (1) systemd unit does not (yet) exist, or
351356
// (2) it has DevicePolicy=auto and empty DeviceAllow list.

libcontainer/configs/cgroup_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,16 @@ type Resources struct {
131131
//
132132
// NOTE it is impossible to start a container which has this flag set.
133133
SkipDevices bool `json:"-"`
134+
135+
// SkipFreezeOnSet is a flag for cgroup manager to skip the cgroup
136+
// freeze when setting resources. Only applicable to systemd legacy
137+
// (i.e. cgroup v1) manager (which uses freeze by default to avoid
138+
// spurious permission errors caused by systemd inability to update
139+
// device rules in a non-disruptive manner).
140+
//
141+
// If not set, a few methods (such as looking into cgroup's
142+
// devices.list and querying the systemd unit properties) are used
143+
// during Set() to figure out whether the freeze is required. Those
144+
// methods may be relatively slow, thus this flag.
145+
SkipFreezeOnSet bool `json:"-"`
134146
}

0 commit comments

Comments
 (0)