Skip to content

Commit 53dbdc6

Browse files
committed
Handling Pausing from freezer state
Signed-off-by: Rajasekaran <[email protected]> freezer status Signed-off-by: Rajasekaran <[email protected]> Fixing review comments Signed-off-by: Rajasekaran <[email protected]> Added comment when freezer not available Signed-off-by: Rajasekaran <[email protected]>
1 parent 05b1cda commit 53dbdc6

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

libcontainer/container_linux.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,27 @@ func (c *linuxContainer) updateState(process parentProcess) error {
775775
return json.NewEncoder(f).Encode(state)
776776
}
777777

778+
func (c *linuxContainer) checkFreezer() (Status, error) {
779+
path := c.cgroupManager.GetPaths()["freezer"]
780+
if _, err := os.Stat(path); err != nil {
781+
if os.IsNotExist(err) {
782+
// Freezer subsystem is not available,Application is neither Checkpointed nor Destroyed
783+
// return the status as Running
784+
return Running, nil
785+
}
786+
}
787+
contents, err := ioutil.ReadFile(filepath.Join(path, "freezer.state"))
788+
if err != nil {
789+
return 0, newSystemError(err)
790+
}
791+
freezerstate := string(contents)
792+
if strings.TrimSpace(freezerstate) == "FROZEN" {
793+
return Paused, nil
794+
}
795+
return Running, nil
796+
797+
}
798+
778799
func (c *linuxContainer) currentStatus() (Status, error) {
779800
if _, err := os.Stat(filepath.Join(c.root, "checkpoint")); err == nil {
780801
return Checkpointed, nil
@@ -789,10 +810,7 @@ func (c *linuxContainer) currentStatus() (Status, error) {
789810
}
790811
return 0, newSystemError(err)
791812
}
792-
if c.config.Cgroups != nil && c.config.Cgroups.Freezer == configs.Frozen {
793-
return Paused, nil
794-
}
795-
return Running, nil
813+
return c.checkFreezer()
796814
}
797815

798816
func (c *linuxContainer) currentState() (*State, error) {

0 commit comments

Comments
 (0)