podman stop: do not cleanup for auto-removal

Do not perform a container clean up for containers configured for
auto-removal (e.g., via `podman run --rm`).  There is a small race
window with the other process performing the removal where a clean up
during podman-stop may fail since the container has already been removed
and cleaned up.  As the removing process will clean up the container,
we don't have to do it during podman-stop.

Fixes: #7384
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg 2020-09-08 12:22:53 +02:00
parent be7778df6c
commit d3e05de156
1 changed files with 6 additions and 0 deletions

View File

@ -174,6 +174,12 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
return err
}
}
if c.AutoRemove() {
// Issue #7384: if the container is configured for
// auto-removal, it might already have been removed at
// this point.
return nil
}
return c.Cleanup(ctx)
})
if err != nil {