Ignore errors when removing containers in DevStack

We don't really care if on unstack the containers doesn't exist, so this
commit makes us ignore those errors.

Change-Id: I3345871e1308c961c375b5c3fac007e7c4d9e625
Closes-Bug: 1877531
This commit is contained in:
Yasufumi Ogawa 2020-05-09 15:14:48 +00:00 committed by Michał Dulko
parent 4ebece5fa6
commit b7a19ece04

View File

@ -16,10 +16,19 @@ XTRACE=$(set +o | grep xtrace)
set -o xtrace
function container_runtime {
# Ignore error at killing/removing a container doesn't running to avoid
# unstack is terminated.
# TODO: Support for CRI-O if it's required.
local regex_cmds_ignore="(kill|rm)\s+"
if [[ ${CONTAINER_ENGINE} == 'crio' ]]; then
sudo podman "$@" || die $LINENO "Error when running podman command"
else
docker "$@" || die $LINENO "Error when running docker command"
if [[ $@ =~ $regex_cmds_ignore ]]; then
docker "$@"
else
docker "$@" || die $LINENO "Error when running docker command"
fi
fi
}