Mark containers invalid earlier during removal

Fixes a bug where we might try saving back to the database during
cleanup, which would fail as the container was already removed
from the database.

Signed-off-by: Matthew Heon <mheon@redhat.com>

Closes: #1001
Approved by: rhatdan
This commit is contained in:
Matthew Heon
2018-06-26 13:30:39 -04:00
committed by Atomic Bot
parent c75f4d4e70
commit 80131339b7

View File

@ -258,6 +258,9 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool)
}
}
// Set container as invalid so it can no longer be used
c.valid = false
// Clean up network namespace, cgroups, mounts
if err := c.cleanup(); err != nil {
if cleanupErr == nil {
@ -289,9 +292,6 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool)
}
}
// Set container as invalid so it can no longer be used
c.valid = false
return cleanupErr
}