mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Fix: Prevent OCI runtime directory remain
This bug was introduced in https://github.com/containers/podman/pull/8906. When we use 'podman rm/restart/stop/kill etc...' command to the container running with --rm, the OCI runtime directory remains at /run/<runtime name> (root user) or /run/user/<user id>/<runtime name> (rootless user). This bug could cause other bugs. For example, when we checkpoint the container running with --rm (podman checkpoint --export) and restore it (podman restore --import) with crun, error message "Error: OCI runtime error: crun: container `<container id>` already exists" is outputted. This error is caused by an attempt to restore the container with the same container ID as the remaining OCI runtime's container ID. Therefore, I fix that the cleanupRuntime() function runs to remove the OCI runtime directory, even if the container has already been removed by --rm option. Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
This commit is contained in:
@ -1309,8 +1309,9 @@ func (c *Container) stop(timeout uint) error {
|
||||
if err := c.syncContainer(); err != nil {
|
||||
switch errors.Cause(err) {
|
||||
// If the container has already been removed (e.g., via
|
||||
// the cleanup process), there's nothing left to do.
|
||||
// the cleanup process), set the container state to "stopped".
|
||||
case define.ErrNoSuchCtr, define.ErrCtrRemoved:
|
||||
c.state.State = define.ContainerStateStopped
|
||||
return stopErr
|
||||
default:
|
||||
if stopErr != nil {
|
||||
|
Reference in New Issue
Block a user