virtcontainers: change container's state to stop asap

container is killed by force, container's state MUST change its state to stop
immediately to avoid leaving it in a bad state.

fixes #1088

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-02-18 11:56:10 -06:00
parent 5201860bb0
commit 62c393c119

View File

@ -928,6 +928,13 @@ func (c *Container) stop() error {
// get failed if the process hasn't exited.
c.sandbox.agent.waitProcess(c, c.id)
// container was killed by force, container MUST change its state
// as soon as possible just in case one of below operations fail leaving
// the containers in a bad state.
if err := c.setContainerState(types.StateStopped); err != nil {
return err
}
if err := c.sandbox.agent.stopContainer(c.sandbox, *c); err != nil {
return err
}
@ -940,7 +947,7 @@ func (c *Container) stop() error {
return err
}
return c.setContainerState(types.StateStopped)
return nil
}
func (c *Container) enter(cmd types.Cmd) (*Process, error) {