Merge pull request #2346 from bergwolf/hostdir

shimv2: clean up properly if vmm quits unexpectedly
This commit is contained in:
Hui Zhu 2019-12-16 10:34:37 +08:00 committed by GitHub
commit 68fc9abc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -17,11 +17,11 @@ import (
)
func deleteContainer(ctx context.Context, s *service, c *container) error {
if !c.cType.IsSandbox() {
status, err := s.sandbox.StatusContainer(c.id)
if err != nil {
return err
}
status, err := s.sandbox.StatusContainer(c.id)
if err != nil && !isNotFound(err) {
return err
}
if !c.cType.IsSandbox() && err == nil {
if status.State.State != types.StateStopped {
_, err = s.sandbox.StopContainer(c.id, false)
if err != nil {

View File

@ -1096,13 +1096,6 @@ func (c *Container) stop(force bool) 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
}
defer func() {
// Save device and drive data.
// TODO: can we merge this saving with setContainerState()?
@ -1133,6 +1126,13 @@ func (c *Container) stop(force bool) error {
return err
}
// 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
}
return nil
}