Skip to content

Commit

Permalink
libct/cg/sd: Don't freeze cgroup on cgroup v2 Set
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit f33be7c, trivial conflict
 due to missing commit b60e2ed)
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
odinuge authored and kolyshkin committed Jul 15, 2021
1 parent 298a310 commit 04edd79
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions libcontainer/cgroups/systemd/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 04edd79

Please sign in to comment.