mirror of
https://github.com/containers/podman.git
synced 2025-10-18 03:33:32 +08:00
Ensure that Cleanup() will not run on active containers
This ensures that containers with active exec sessions will not have storage unmounted under them or network namespaces destroyed Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #412 Approved by: baude
This commit is contained in:
@ -603,6 +603,16 @@ func (c *Container) Cleanup() error {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if state is good
|
||||
if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused {
|
||||
return errors.Wrapf(ErrCtrStateInvalid, "container %s is running or paused, refusing to clean up", c.ID())
|
||||
}
|
||||
|
||||
// Check if we have active exec sessions
|
||||
if len(c.state.ExecSessions) != 0 {
|
||||
return errors.Wrapf(ErrCtrStateInvalid, "container %s has active exec sessions, refusing to clean up", c.ID())
|
||||
}
|
||||
|
||||
// Stop the container's network namespace (if it has one)
|
||||
if err := c.cleanupNetwork(); err != nil {
|
||||
logrus.Errorf("unable cleanup network for container %s: %q", c.ID(), err)
|
||||
|
Reference in New Issue
Block a user