Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
tests: Retry rm'ing container
Browse files Browse the repository at this point in the history
Example where this would be needed:
```
docker rm -f 4fcd7c2012b6
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
time="2022-08-09T17:22:11Z" level=error msg="container \"4fcd7c2012b63e6bf9bffd9b7d490d12f1d557ba924e889192ec858821019d91\" does not exist"

Error: cannot remove container 4fcd7c2012b63e6bf9bffd9b7d490d12f1d557ba924e889192ec858821019d91 as it could not be stopped: timed out waiting for file /tmp/podman-run-1111/libpod/tmp/exits/4fcd7c2012b63e6bf9bffd9b7d490d12f1d557ba924e889192ec858821019d91: internal libpod error
docker rm -f 4fcd7c2012b6
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
ERRO[0000] Joining network namespace for container 4fcd7c2012b63e6bf9bffd9b7d490d12f1d557ba924e889192ec858821019d91: error retrieving network namespace at /tmp/podman-run-1111/netns/netns-600d6718-1a5e-2fed-bf39-ad7048004be2: unknown FS magic on "/tmp/podman-run-1111/netns/netns-600d6718-1a5e-2fed-bf39-ad7048004be2": ef53
4fcd7c2012b63e6bf9bffd9b7d490d12f1d557ba924e889192ec858821019d91
```

See containers/podman#13227

This also makes the function fail fatally.

Signed-off-by: David Galloway <[email protected]>
  • Loading branch information
David Galloway committed Aug 9, 2022
1 parent 1f81a89 commit 1286280
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/tox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,17 @@ bash "$WORKSPACE"/travis-builds/purge_cluster.sh
containers_to_remove=$(docker ps -a -q)

if [ "${containers_to_remove}" ]; then
docker rm -f "$@" "${containers_to_remove}" || echo failed to remove containers
ATTEMPTS=0
NUM_CONTAINERS=$(docker ps -a -q | wc -l)
until [ "$ATTEMPTS" -eq 5 ] || [ "$NUM_CONTAINERS" -eq 0 ]; do
docker rm -f "$@" "${containers_to_remove}"
(( ATTEMPTS++ ))
NUM_CONTAINERS=$(docker ps -a -q | wc -l)
done
if [ "$ATTEMPTS" -eq 5 ]; then
echo "Removing containers failed"
exit 1
fi
fi

cd "$WORKSPACE"
Expand Down

0 comments on commit 1286280

Please sign in to comment.