From aad29e759c78b415a3b0393d7aba2bddbbc0cd3e Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 7 Sep 2022 11:45:30 +0200 Subject: health check: add on-failure actions For systems that have extreme robustness requirements (edge devices, particularly those in difficult to access environments), it is important that applications continue running in all circumstances. When the application fails, Podman must restart it automatically to provide this robustness. Otherwise, these devices may require customer IT to physically gain access to restart, which can be prohibitively difficult. Add a new `--on-failure` flag that supports four actions: - **none**: Take no action. - **kill**: Kill the container. - **restart**: Restart the container. Do not combine the `restart` action with the `--restart` flag. When running inside of a systemd unit, consider using the `kill` or `stop` action instead to make use of systemd's restart policy. - **stop**: Stop the container. To remain backwards compatible, **none** is the default action. Signed-off-by: Valentin Rothberg --- test/system/220-healthcheck.bats | 96 ++++++++++++++++++++++++---------------- test/system/250-systemd.bats | 51 +++++++++++++++++++++ test/system/helpers.bash | 54 ++++++++++++++++++++++ 3 files changed, 164 insertions(+), 37 deletions(-) (limited to 'test/system') diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index c502ad669..00ec1dd79 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -20,44 +20,8 @@ function _check_health { done } - @test "podman healthcheck" { - # Create an image with a healthcheck script; said script will - # pass until the file /uh-oh gets created (by us, via exec) - cat >${PODMAN_TMPDIR}/healthcheck <&2 - exit 1 -else - echo "Life is Good on stdout" - echo "Life is Good on stderr" >&2 - exit 0 -fi -EOF - - cat >${PODMAN_TMPDIR}/entrypoint <${PODMAN_TMPDIR}/Containerfile <${PODMAN_TMPDIR}/healthcheck <&2 + ${cleanfile} + exit 1 +else + echo "Life is Good on stdout" + echo "Life is Good on stderr" >&2 + exit 0 +fi +EOF + + cat >${PODMAN_TMPDIR}/entrypoint <${PODMAN_TMPDIR}/Containerfile <