@@ -27,9 +27,18 @@ func (s *FreezerGroup) Apply(path string, d *cgroupData) error {
27
27
return join (path , d .pid )
28
28
}
29
29
30
- func (s * FreezerGroup ) Set (path string , cgroup * configs.Cgroup ) error {
30
+ func (s * FreezerGroup ) Set (path string , cgroup * configs.Cgroup ) ( Err error ) {
31
31
switch cgroup .Resources .Freezer {
32
32
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
+
33
42
// As per older kernel docs (freezer-subsystem.txt before
34
43
// kernel commit ef9fe980c6fcc1821), if FREEZING is seen,
35
44
// userspace should either retry or thaw. While current
@@ -75,9 +84,6 @@ func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) error {
75
84
}
76
85
}
77
86
// 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 ))
81
87
return errors .New ("unable to freeze" )
82
88
case configs .Thawed :
83
89
return fscommon .WriteFile (path , "freezer.state" , string (configs .Thawed ))
0 commit comments