Blame SOURCES/bz1508362-docker-improve-exit-reasons.patch

bb196a
diff -uNr a/heartbeat/docker b/heartbeat/docker
bb196a
--- a/heartbeat/docker	2017-11-01 13:57:09.742513891 +0100
bb196a
+++ b/heartbeat/docker	2017-11-01 13:59:20.632338967 +0100
bb196a
@@ -303,11 +303,21 @@
bb196a
 		# we already know at this point it wouldn't be running 
bb196a
 		remove_container
bb196a
 		ocf_log info "running container $CONTAINER for the first time"
bb196a
-		ocf_run docker run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd
bb196a
+		output=`docker run $run_opts $OCF_RESKEY_image $OCF_RESKEY_run_cmd 2>&1`
bb196a
+		rc=$?
bb196a
+
bb196a
+		if [ $rc -ne 0 ]; then
bb196a
+			reason=`echo $output | sed -e 's@See ./usr/bin.*@@' -e 's@.*Error response from daemon: @@' -e 's@[^\:]*:@@'`
bb196a
+			ocf_exit_reason "$reason"
bb196a
+			ocf_log err "$output"
bb196a
+			ocf_run -info docker ps -a
bb196a
+			return $OCF_ERR_GENERIC
bb196a
+		fi
bb196a
 	fi
bb196a
 
bb196a
 	if [ $? -ne 0 ]; then
bb196a
 		ocf_exit_reason "docker failed to launch container"
bb196a
+		ocf_run -info docker ps -a
bb196a
 		return $OCF_ERR_GENERIC
bb196a
 	fi
bb196a