Permalink
Browse files

Merge pull request #1610 from sboeuf/fix_freezer_state

libcontainer: cgroups: Write freezer state after every state check
  • Loading branch information...
mrunalp committed Oct 12, 2017
2 parents beb8716 + acb93c9 commit 7c7d38bfe8b1a70dca1582bcd8ca91fc26cb9904
Showing with 9 additions and 4 deletions.
  1. +9 −4 libcontainer/cgroups/fs/freezer.go
@@ -29,18 +29,23 @@ func (s *FreezerGroup) Apply(d *cgroupData) error {
func (s *FreezerGroup) Set(path string, cgroup *configs.Cgroup) error {
switch cgroup.Resources.Freezer {
case configs.Frozen, configs.Thawed:
if err := writeFile(path, "freezer.state", string(cgroup.Resources.Freezer)); err != nil {
return err
}
for {
// In case this loop does not exit because it doesn't get the expected
// state, let's write again this state, hoping it's going to be properly
// set this time. Otherwise, this loop could run infinitely, waiting for
// a state change that would never happen.
if err := writeFile(path, "freezer.state", string(cgroup.Resources.Freezer)); err != nil {
return err
}
state, err := readFile(path, "freezer.state")
if err != nil {
return err
}
if strings.TrimSpace(state) == string(cgroup.Resources.Freezer) {
break
}
time.Sleep(1 * time.Millisecond)
}
case configs.Undefined:

0 comments on commit 7c7d38b

Please sign in to comment.