refreshState needs to be called to verify that the current state on the container is what is true. Because consumers of libcontainer can use it out of process we need to verify the container's status based on runtime information and not rely on our in process info.
()
| 872 | // out of process we need to verify the container's status based on runtime |
| 873 | // information and not rely on our in process info. |
| 874 | func (c *Container) refreshState() error { |
| 875 | paused, err := c.isPaused() |
| 876 | if err != nil { |
| 877 | return err |
| 878 | } |
| 879 | if paused { |
| 880 | return c.state.transition(&pausedState{c: c}) |
| 881 | } |
| 882 | if !c.hasInit() { |
| 883 | return c.state.transition(&stoppedState{c: c}) |
| 884 | } |
| 885 | // The presence of exec fifo helps to distinguish between |
| 886 | // the created and the running states. |
| 887 | if _, err := os.Stat(filepath.Join(c.stateDir, execFifoFilename)); err == nil { |
| 888 | return c.state.transition(&createdState{c: c}) |
| 889 | } |
| 890 | return c.state.transition(&runningState{c: c}) |
| 891 | } |
| 892 | |
| 893 | // hasInit tells whether the container init process exists. |
| 894 | func (c *Container) hasInit() bool { |
no test coverage detected