diff options
author | Paul Holzinger <pholzing@redhat.com> | 2021-09-01 11:39:42 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2021-09-01 12:56:38 +0200 |
commit | a55f595fe1b84edc20c68c10f264fab82e687364 (patch) | |
tree | 6127405a3db421a459781a3beb503f43cf358a95 /pkg/domain/infra/abi | |
parent | bebaef26fdd5d3ae8a29f04d36c437f316fc1bc8 (diff) | |
download | podman-a55f595fe1b84edc20c68c10f264fab82e687364.tar.gz podman-a55f595fe1b84edc20c68c10f264fab82e687364.tar.bz2 podman-a55f595fe1b84edc20c68c10f264fab82e687364.zip |
podman stop always cleanup
When a container is configured for auto removal podman stop should still
do cleanup, there is no guarantee the the cleanup process spawned by
conmon will be successful. Also a user expects after podman stop that
the network/mounts are cleaned up. Therefore podman stop should not return
early and instead do the cleanup and ignore errors if the container was
already removed.
[NO TESTS NEEDED] I don't know how to test this.
Fixes #11384
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index 8b2a5bfae..ff34ec86b 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -173,13 +173,17 @@ 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 + err = c.Cleanup(ctx) + if err != nil { + // Issue #7384 and #11384: If the container is configured for + // auto-removal, it might already have been removed at this point. + // We still need to to cleanup since we do not know if the other cleanup process is successful + if c.AutoRemove() && (errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved)) { + return nil + } + return err } - return c.Cleanup(ctx) + return nil }) if err != nil { return nil, err |