Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion fs2/freezer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/opencontainers/cgroups"
)

func setFreezer(dirPath string, state cgroups.FreezerState) error {
func setFreezer(dirPath string, state cgroups.FreezerState) (retErr error) {
var stateStr string
switch state {
case cgroups.Undefined:
Expand All @@ -38,6 +38,17 @@ func setFreezer(dirPath string, state cgroups.FreezerState) error {
}
defer fd.Close()

// If freezing fails (for example the freeze times out), reset the cgroup
// back to thawed so it is not left in a half-frozen state. This mirrors
// the cgroup v1 behaviour (see runc#2774).
if state == cgroups.Frozen {
defer func() {
if retErr != nil {
_ = cgroups.WriteFile(dirPath, "cgroup.freeze", "0")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not fd.WriteString("0")?

}
}()
}

if _, err := fd.WriteString(stateStr); err != nil {
return err
}
Expand Down
Loading