|
|
c608c9 |
From c25542d8808640fae7fad39e27e95e83ffde2e31 Mon Sep 17 00:00:00 2001
|
|
|
c608c9 |
From: David Vossel <dvossel@redhat.com>
|
|
|
c608c9 |
Date: Mon, 27 Oct 2014 18:22:27 -0400
|
|
|
c608c9 |
Subject: [PATCH] Low: docker: indicate when monitor_cmd is not available after
|
|
|
c608c9 |
startup
|
|
|
c608c9 |
|
|
|
c608c9 |
---
|
|
|
c608c9 |
heartbeat/docker | 29 ++++++++++++++++++++++-------
|
|
|
c608c9 |
1 file changed, 22 insertions(+), 7 deletions(-)
|
|
|
c608c9 |
|
|
|
c608c9 |
diff --git a/heartbeat/docker b/heartbeat/docker
|
|
|
c608c9 |
index 929b26b..a0dcee4 100755
|
|
|
c608c9 |
--- a/heartbeat/docker
|
|
|
c608c9 |
+++ b/heartbeat/docker
|
|
|
c608c9 |
@@ -168,15 +168,28 @@ END
|
|
|
c608c9 |
monitor_cmd_exec()
|
|
|
c608c9 |
{
|
|
|
c608c9 |
local rc=$OCF_SUCCESS
|
|
|
c608c9 |
- if [ -n "$OCF_RESKEY_monitor_cmd" ]; then
|
|
|
c608c9 |
- out=$(echo "$OCF_RESKEY_monitor_cmd" | nsenter --target $(docker inspect --format {{.State.Pid}} ${CONTAINER}) --mount --uts --ipc --net --pid 2>&1)
|
|
|
c608c9 |
- rc=$?
|
|
|
c608c9 |
- if [ $rc -ne 0 ]; then
|
|
|
c608c9 |
- ocf_log info "monitor cmd failed with exit code $rc"
|
|
|
c608c9 |
- ocf_log info "stdout/stderr: $out"
|
|
|
c608c9 |
- rc=$OCF_ERR_GENERIC
|
|
|
c608c9 |
+ local out
|
|
|
c608c9 |
+
|
|
|
c608c9 |
+ if [ -z "$OCF_RESKEY_monitor_cmd" ]; then
|
|
|
c608c9 |
+ return $rc
|
|
|
c608c9 |
+ fi
|
|
|
c608c9 |
+
|
|
|
c608c9 |
+ out=$(echo "$OCF_RESKEY_monitor_cmd" | nsenter --target $(docker inspect --format {{.State.Pid}} ${CONTAINER}) --mount --uts --ipc --net --pid 2>&1)
|
|
|
c608c9 |
+ rc=$?
|
|
|
c608c9 |
+ if [ $rc -ne 0 ]; then
|
|
|
c608c9 |
+ ocf_log info "monitor cmd exit code = $rc"
|
|
|
c608c9 |
+ ocf_log info "stdout/stderr: $out"
|
|
|
c608c9 |
+
|
|
|
c608c9 |
+ if [ $rc -eq 127 ]; then
|
|
|
c608c9 |
+ ocf_exit_reason "monitor_cmd, ${OCF_RESKEY_monitor_cmd} , not found within container."
|
|
|
c608c9 |
+ # there is no recovering from this, exit immediately
|
|
|
c608c9 |
+ exit $OCF_ERR_ARGS
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
+ rc=$OCF_ERR_GENERIC
|
|
|
c608c9 |
+ else
|
|
|
c608c9 |
+ ocf_log info "monitor cmd passed: exit code = $rc"
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
+
|
|
|
c608c9 |
return $rc
|
|
|
c608c9 |
}
|
|
|
c608c9 |
|
|
|
c608c9 |
@@ -288,6 +301,7 @@ docker_start()
|
|
|
c608c9 |
|
|
|
c608c9 |
monitor_cmd_exec
|
|
|
c608c9 |
if [ $? -eq $OCF_SUCCESS ]; then
|
|
|
c608c9 |
+ ocf_log notice "Container $CONTAINER started successfully"
|
|
|
c608c9 |
return $OCF_SUCCESS
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
|
|
|
c608c9 |
@@ -365,6 +379,7 @@ docker_validate()
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
|
|
|
c608c9 |
if [ -n "$OCF_RESKEY_monitor_cmd" ]; then
|
|
|
c608c9 |
+ ocf_log info "checking for nsenter, which is required when 'monitor_cmd' is specified"
|
|
|
c608c9 |
check_binary nsenter
|
|
|
c608c9 |
fi
|
|
|
c608c9 |
|
|
|
c608c9 |
--
|
|
|
c608c9 |
1.8.4.2
|
|
|
c608c9 |
|