diff options
| author | Martin Hiner <m.hiner@partner.samsung.com> | 2022-11-21 18:38:57 +0100 |
|---|---|---|
| committer | Martin Hiner <m.hiner@partner.samsung.com> | 2023-04-28 16:16:55 +0200 |
| commit | 53e8b80ed36a9193627862427fa224ed38375d3a (patch) | |
| tree | 14463dda4a87452345c37a1a5252d50db057bc12 /tests/check-failure.sh | |
| parent | 92ddbdfbc190ec430f5527fcf867efec97e455b4 (diff) | |
| download | kolla-ansible-53e8b80ed36a9193627862427fa224ed38375d3a.tar.gz kolla-ansible-53e8b80ed36a9193627862427fa224ed38375d3a.zip | |
Add container engine option to scripts
This patch add a way to choose container engine inside tool and test
scripts. This is in preparation for Podman introduction but still
leaves Docker as default container engine.
Signed-off-by: Martin Hiner <m.hiner@partner.samsung.com>
Change-Id: I395d2bdb0dfb4b325b6ad197c8893c8a0f768324
Diffstat (limited to 'tests/check-failure.sh')
| -rwxr-xr-x | tests/check-failure.sh | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/check-failure.sh b/tests/check-failure.sh index b62e6ffcc..ad88b29de 100755 --- a/tests/check-failure.sh +++ b/tests/check-failure.sh @@ -7,7 +7,22 @@ set -o errexit export PYTHONUNBUFFERED=1 -check_failure() { +check_podman_failures() { + failed_containers=$(sudo podman ps -a --format "{{.Names}}" \ + --filter status=created \ + --filter status=paused \ + --filter status=exited \ + --filter status=unknown) +} + + +check_podman_unhealthies() { + unhealthy_containers=$(sudo podman ps -a --format "{{.Names}}" \ + --filter health=unhealthy) +} + + +check_docker_failures() { # All docker container's status are created, restarting, running, removing, # paused, exited and dead. Containers without running status are treated as # failure. removing is added in docker 1.13, just ignore it now. @@ -19,9 +34,26 @@ check_failure() { --filter status=paused \ --filter status=exited \ --filter status=dead) +} + +check_docker_unhealthies() { unhealthy_containers=$(sudo docker ps -a --format "{{.Names}}" \ --filter health=unhealthy) +} + + +check_failure() { + if [ "$CONTAINER_ENGINE" = "docker" ]; then + check_docker_failures + check_docker_unhealthies + elif [ "$CONTAINER_ENGINE" = "podman" ]; then + check_podman_failures + check_podman_unhealthies + else + echo "Invalid container engine: ${CONTAINER_ENGINE}" + exit 1 + fi if [[ -n "$unhealthy_containers" ]]; then exit 1; |
