Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: change container's state to stop asap
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Julio Montes committed Feb 19, 2019
1 parent 5201860 commit 62c393c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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) {
Expand Down

0 comments on commit 62c393c

Please sign in to comment.