Fallback to a rm -f action for podman

There is a podman specific behavior that cannot be reproduced with
docker:

$ docker run -itd --privileged --name=foo busybox sleep 1000
$ docker exec -it foo sh -c "sleep 180"
$ kill -STOP <that process>
$ docker stop foo
$ docker rm foo

works w/o errors, while podman fails the latter step:
Error: cannot remove container <id> has active exec sessions: container
state improper

To make it consistent, add a fallback to re-try it with rm -f.

Related-bug: #1860004
Change-Id: Id387f624078ef874aa902656952582c9c54f3f2e
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
Bogdan Dobrelya 2020-02-18 12:10:57 +01:00
parent 8489a0cfbe
commit 3006b547cb
1 changed files with 7 additions and 1 deletions

View File

@ -287,8 +287,14 @@ class BaseRunner(object):
cmd = [self.cont_cmd, 'rm', container]
cmd_stdout, cmd_stderr, returncode = self.execute(cmd, self.log)
if returncode != 0:
self.log.error('Error removing container: %s' % container)
self.log.error('Error removing container '
'gracefully: %s' % container)
self.log.error(cmd_stderr)
cmd = [self.cont_cmd, 'rm', '-f', container]
cmd_stdout, cmd_stderr, returncode = self.execute(cmd, self.log)
if returncode != 0:
self.log.error('Error removing container: %s' % container)
self.log.error(cmd_stderr)
def stop_container(self, container, cont_cmd=None, quiet=False):
cont_cmd = cont_cmd or self.cont_cmd