diff options
author | Valentin Rothberg <vrothberg@redhat.com> | 2022-10-07 10:29:49 +0200 |
---|---|---|
committer | Valentin Rothberg <vrothberg@redhat.com> | 2022-10-07 15:43:48 +0200 |
commit | 02040089a6c3eb96f231974cdaa4158dc894b5eb (patch) | |
tree | fb30b2ba012f5a9d8423e44ed3f39487e0add748 /test | |
parent | d33a31524a275245b9535871208a2858ba517ed0 (diff) | |
download | podman-02040089a6c3eb96f231974cdaa4158dc894b5eb.tar.gz podman-02040089a6c3eb96f231974cdaa4158dc894b5eb.tar.bz2 podman-02040089a6c3eb96f231974cdaa4158dc894b5eb.zip |
health checks: make on-failure action retry aware
Make sure that the on-failure actions only kick in once the health check
has passed its retries. Also fix race conditions on reading/writing the
log.
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/system/220-healthcheck.bats | 9 | ||||
-rw-r--r-- | test/system/250-systemd.bats | 1 |
2 files changed, 6 insertions, 4 deletions
diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index a1b24d293..8e14adcec 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -28,10 +28,11 @@ function _check_health { --health-cmd /healthcheck \ --health-interval 1s \ --health-retries 3 \ + --health-on-failure=kill \ healthcheck_i run_podman inspect healthcheck_c --format "{{.Config.HealthcheckOnFailureAction}}" - is "$output" "none" "default on-failure action is none" + is "$output" "kill" "on-failure action is set to kill" # We can't check for 'starting' because a 1-second interval is too # short; it could run healthcheck before we get to our first check. @@ -67,9 +68,8 @@ Log[-1].ExitCode | 1 Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\" " - # healthcheck should now fail, with exit status 1 and 'unhealthy' output - run_podman 1 healthcheck run healthcheck_c - is "$output" "unhealthy" "output from 'podman healthcheck run'" + # now the on-failure should kick in and kill the container + podman wait healthcheck_c # Clean up run_podman rm -t 0 -f healthcheck_c @@ -95,6 +95,7 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\" # Run that healthcheck image. run_podman run -d --name $ctr \ --health-cmd /healthcheck \ + --health-retries=1 \ --health-on-failure=$policy \ $img diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index ddec3a492..5526728b6 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -318,6 +318,7 @@ LISTEN_FDNAMES=listen_fdnames" | sort) run_podman create --name $cname \ --health-cmd /healthcheck \ --health-on-failure=kill \ + --health-retries=1 \ --restart=on-failure \ $img |