Skip to content
Closed
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
26 changes: 22 additions & 4 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,27 @@ func (c *linuxContainer) updateState(process parentProcess) error {
return json.NewEncoder(f).Encode(state)
}

func (c *linuxContainer) checkFreezer() (Status, error) {
path := c.cgroupManager.GetPaths()["freezer"]
if _, err := os.Stat(path); err != nil {
if os.IsNotExist(err) {
// Freezer subsystem is not available,Application is neither Checkpointed nor Destroyed
// return the status as Running
Copy link
Contributor

Choose a reason for hiding this comment

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

The commend seems a bit odd to me, isn't Checkpointed already checked before this function is called?

return Running, nil
Copy link
Member

Choose a reason for hiding this comment

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

this seems a little weird to have here. Maybe a comment explaining why the status would be running if the error is an IsNotExist error.

}
Copy link
Member

Choose a reason for hiding this comment

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

I think you are missing a return 0, err here

}
contents, err := ioutil.ReadFile(filepath.Join(path, "freezer.state"))
if err != nil {
return 0, newSystemError(err)
}
freezerstate := string(contents)
if strings.TrimSpace(freezerstate) == "FROZEN" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should check both FROZEN and FREEZING here, we have pausing defined but never used, it should be returned here.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Mon, Sep 07, 2015 at 12:01:35AM -0700, Qiang Huang wrote:

Maybe we should check both FROZEN and FREEZING here, we have
pausing defined but never used, it should be returned here.

Previous thoughts on model state settings in [1,2,3]. But if we
already have state constants for each of Linux's three settings, I
think it makes sense to use them (at least until the runtime-agnostic
spec has something to say about freezing).

return Paused, nil
}
return Running, nil

}

func (c *linuxContainer) currentStatus() (Status, error) {
if _, err := os.Stat(filepath.Join(c.root, "checkpoint")); err == nil {
return Checkpointed, nil
Expand All @@ -789,10 +810,7 @@ func (c *linuxContainer) currentStatus() (Status, error) {
}
return 0, newSystemError(err)
}
if c.config.Cgroups != nil && c.config.Cgroups.Freezer == configs.Frozen {
return Paused, nil
}
return Running, nil
return c.checkFreezer()
}

func (c *linuxContainer) currentState() (*State, error) {
Expand Down