Blame SOURCES/bz1734062-podman-2-improve-monitor-action.patch

a89620
From 9685e8e6bf2896377a9cf0e07a85de5dd5fcf2df Mon Sep 17 00:00:00 2001
a89620
From: Michele Baldessari <michele@acksyn.org>
a89620
Date: Wed, 12 Jun 2019 12:00:31 +0200
a89620
Subject: [PATCH] Simplify podman_monitor()
a89620
a89620
Before this change podman_monitor() does two things:
a89620
\-> podman_simple_status()
a89620
    \-> podman inspect {{.State.Running}}
a89620
\-> if podman_simple_status == 0 then monitor_cmd_exec()
a89620
    \-> if [ -z "$OCF_RESKEY_monitor_cmd" ]; then # so if OCF_RESKEY_monitor_cmd is empty we just return SUCCESS
a89620
          return $rc
a89620
        fi
a89620
        # if OCF_RESKEY_monitor_cmd is set to something we execute it
a89620
        podman exec ${CONTAINER} $OCF_RESKEY_monitor_cmd
a89620
a89620
Let's actually only rely on podman exec as invoked inside monitor_cmd_exec
a89620
when $OCF_RESKEY_monitor_cmd is non empty (which is the default as it is set to "/bin/true").
a89620
When there is no monitor_cmd command defined then it makes sense to rely on podman inspect
a89620
calls container in podman_simple_status().
a89620
a89620
Tested as follows:
a89620
1) Injected the change on an existing bundle-based cluster
a89620
2) Observed that monitoring operations kept working okay
a89620
3) Restarted rabbitmq-bundle and galera-bundle successfully
a89620
4) Killed a container and we correctly detected the monitor failure
a89620
Jun 12 09:52:12 controller-0 pacemaker-controld[25747]: notice: controller-0-haproxy-bundle-podman-1_monitor_60000:230 [ ocf-exit-reason:monitor cmd failed (rc=125), output: cannot exec into container that is not running\n ]
a89620
5) Container correctly got restarted after the monitor failure:
a89620
   haproxy-bundle-podman-1      (ocf::heartbeat:podman):        Started controller-0
a89620
6) Stopped and removed a container and pcmk detected it correctly:
a89620
Jun 12 09:55:15 controller-0 podman(haproxy-bundle-podman-1)[841411]: ERROR: monitor cmd failed (rc=125), output: unable to exec into haproxy-bundle-podman-1: no container with name or ID haproxy-bundle-podman-1 found: no such container
a89620
Jun 12 09:55:15 controller-0 pacemaker-execd[25744]: notice: haproxy-bundle-podman-1_monitor_60000:841411:stderr [ ocf-exit-reason:monitor cmd failed (rc=125), output: unable to exec into haproxy-bundle-podman-1: no container with name or ID haproxy-bundle-podman-1 found: no such container ]
a89620
7) pcmk was able to start the container that was stopped and removed:
a89620
Jun 12 09:55:16 controller-0 pacemaker-controld[25747]: notice: Result of start operation for haproxy-bundle-podman-1 on controller-0: 0 (ok)
a89620
8) Added 'set -x' to the RA and correctly observed that no 'podman inspect' has been invoked during monitoring operations
a89620
a89620
Signed-off-by: Michele Baldessari <michele@acksyn.org>
a89620
---
a89620
 heartbeat/podman | 11 +++--------
a89620
 1 file changed, 3 insertions(+), 8 deletions(-)
a89620
a89620
diff --git a/heartbeat/podman b/heartbeat/podman
a89620
index b2b3081f9..a9bd57dea 100755
a89620
--- a/heartbeat/podman
a89620
+++ b/heartbeat/podman
a89620
@@ -255,15 +255,10 @@ podman_simple_status()
a89620
 
a89620
 podman_monitor()
a89620
 {
a89620
-	local rc=0
a89620
-
a89620
-	podman_simple_status
a89620
-	rc=$?
a89620
-
a89620
-	if [ $rc -ne 0 ]; then
a89620
-		return $rc
a89620
+	if [ -z "$OCF_RESKEY_monitor_cmd" ]; then
a89620
+		podman_simple_status
a89620
+		return $?
a89620
 	fi
a89620
-
a89620
 	monitor_cmd_exec
a89620
 }
a89620