From 04edd79d39c53519e8e329da8819eec40f8cbb0b Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Wed, 7 Jul 2021 13:39:30 +0200 Subject: [PATCH] libct/cg/sd: Don't freeze cgroup on cgroup v2 Set Since device updates in cgroup v2 are atomic for systemd, there is no need to freeze the processes before running the updates. Signed-off-by: Odin Ugedal (cherry picked from commit f33be7cc981943b5412, trivial conflict due to missing commit b60e2edf75539b144374a) Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/systemd/v2.go | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/libcontainer/cgroups/systemd/v2.go b/libcontainer/cgroups/systemd/v2.go index 262aaca85..8176ce5b2 100644 --- a/libcontainer/cgroups/systemd/v2.go +++ b/libcontainer/cgroups/systemd/v2.go @@ -418,35 +418,10 @@ func (m *unifiedManager) Set(r *configs.Resources) error { return err } - // Figure out the current freezer state, so we can revert to it after we - // temporarily freeze the container. - targetFreezerState, err := m.GetFreezerState() - if err != nil { - return err - } - if targetFreezerState == configs.Undefined { - targetFreezerState = configs.Thawed - } - - // We have to freeze the container while systemd sets the cgroup settings. - // The reason for this is that systemd's application of DeviceAllow rules - // is done disruptively, resulting in spurrious errors to common devices - // (unlike our fs driver, they will happily write deny-all rules to running - // containers). So we freeze the container to avoid them hitting the cgroup - // error. But if the freezer cgroup isn't supported, we just warn about it. - if err := m.Freeze(configs.Frozen); err != nil { - logrus.Infof("freeze container before SetUnitProperties failed: %v", err) - } - if err := setUnitProperties(m.dbus, getUnitName(m.cgroups), properties...); err != nil { - _ = m.Freeze(targetFreezerState) return errors.Wrap(err, "error while setting unit properties") } - // Reset freezer state before we apply the configuration, to avoid clashing - // with the freezer setting in the configuration. - _ = m.Freeze(targetFreezerState) - fsMgr, err := m.fsManager() if err != nil { return err