resource-agents/SOURCES/bz1986868-podman-return-not...

43 lines
1.2 KiB
Diff

From 6877b20a83cb691884996bf77385259388fdebb2 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Wed, 3 Mar 2021 17:06:12 +0100
Subject: [PATCH] podman: return OCF_NOT_RUNNING when monitor cmd fails (not
running)
---
heartbeat/podman | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/heartbeat/podman b/heartbeat/podman
index 82ea14624..5b707f3f5 100755
--- a/heartbeat/podman
+++ b/heartbeat/podman
@@ -204,14 +204,19 @@ monitor_cmd_exec()
# 125: no container with name or ID ${CONTAINER} found
# 126: container state improper (not running)
# 127: any other error
- if [ $rc -eq 125 ] || [ $rc -eq 126 ]; then
- rc=$OCF_NOT_RUNNING
- elif [ $rc -ne 0 ]; then
- ocf_exit_reason "monitor cmd failed (rc=$rc), output: $out"
- rc=$OCF_ERR_GENERIC
- else
- ocf_log debug "monitor cmd passed: exit code = $rc"
- fi
+ # 255: podman 2+: container not running
+ case "$rc" in
+ 125|126|255)
+ rc=$OCF_NOT_RUNNING
+ ;;
+ 0)
+ ocf_log debug "monitor cmd passed: exit code = $rc"
+ ;;
+ *)
+ ocf_exit_reason "monitor cmd failed (rc=$rc), output: $out"
+ rc=$OCF_ERR_GENERIC
+ ;;
+ esac
return $rc
}