Skip to content

Commit 93d7d28

Browse files
Merge pull request #51 from saschagrunert/rhaos-4.8
[4.8] libct/cg/fs/freezer: make sure to thaw on failure
2 parents cd80260 + 354a28f commit 93d7d28

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

libcontainer/cgroups/fs/freezer.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@ func (s *FreezerGroup) Apply(path string, d *cgroupData) error {
2727
return join(path, d.pid)
2828
}
2929

30-
func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) error {
30+
func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) (Err error) {
3131
switch cgroup.Resources.Freezer {
3232
case configs.Frozen:
33+
defer func() {
34+
if Err != nil {
35+
// Freezing failed, and it is bad and dangerous
36+
// to leave the cgroup in FROZEN or FREEZING
37+
// state, so (try to) thaw it back.
38+
_ = fscommon.WriteFile(path, "freezer.state", string(configs.Thawed))
39+
}
40+
}()
41+
3342
// As per older kernel docs (freezer-subsystem.txt before
3443
// kernel commit ef9fe980c6fcc1821), if FREEZING is seen,
3544
// userspace should either retry or thaw. While current
@@ -75,9 +84,6 @@ func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) error {
7584
}
7685
}
7786
// Despite our best efforts, it got stuck in FREEZING.
78-
// Leaving it in this state is bad and dangerous, so
79-
// let's (try to) thaw it back and error out.
80-
_ = fscommon.WriteFile(path, "freezer.state", string(configs.Thawed))
8187
return errors.New("unable to freeze")
8288
case configs.Thawed:
8389
return fscommon.WriteFile(path, "freezer.state", string(configs.Thawed))

0 commit comments

Comments
 (0)