booth/0006-Feature-alternative-logger-in-service-runnable-scrip.patch
Jan Pokorný 0c140f2bb9
1.0-3.570876d.git - update per the changesets recently accepted
...by the upstream (memory/resource leaks fixes, patches previously
attached separately that make unit test pass, internal cleanups, etc.)

Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
2016-05-25 10:14:11 +02:00

203 lines
5.8 KiB
Diff

From 2531e70e3014ae80d1799478b1cd95aa2076a484 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
Date: Wed, 2 Mar 2016 19:38:46 +0100
Subject: [PATCH 6/6] Feature: alternative logger (in service-runnable script)
This effectively eliminates the last dependency on glue project as such.
---
Makefile.am | 2 +-
configure.ac | 5 ++++
script/service-runnable | 62 ----------------------------------------------
script/service-runnable.in | 61 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 67 insertions(+), 63 deletions(-)
delete mode 100755 script/service-runnable
create mode 100755 script/service-runnable.in
diff --git a/Makefile.am b/Makefile.am
index 5f360c4..076d461 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,7 +66,7 @@ bootharbitrator_SCRIPTS = script/lsb/booth-arbitrator
boothnoarchdir = $(datadir)/$(PACKAGE_NAME)
-boothnoarch_SCRIPTS = script/service-runnable
+nodist_boothnoarch_SCRIPTS = script/service-runnable
sbin_SCRIPTS = script/booth-keygen
diff --git a/configure.ac b/configure.ac
index cb4eeb1..f67c972 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,8 @@ AC_CONFIG_FILES([Makefile
src/Makefile
docs/Makefile])
+AC_CONFIG_FILES([script/service-runnable], [chmod +x script/service-runnable])
+
# ===============================================
# Helpers
# ===============================================
@@ -230,6 +232,7 @@ if test "x$logging_provider" = "x" && test "x$with_glue" = "xno"; then
fi
case "$logging_provider" in
libplumb)
+ LOGGER="ha_logger"
;;
libqb)
PKG_CHECK_MODULES([LIBQB], [libqb])
@@ -238,12 +241,14 @@ libqb)
[AC_DEFINE([LOGGING_LIBQB_MAJOR], [1],
[libqb major version lower bound])],
[AC_MSG_WARN([[syslog identifier will not get changed]])])
+ LOGGER="logger -t booth-script"
;;
*)
AC_MSG_ERROR([logging provider required (libplumb, or libqb when --without-glue)])
;;
esac
AM_CONDITIONAL([LOGGING_LIBQB], [test "x$logging_provider" = "xlibqb"])
+AC_SUBST([LOGGER])
# figure out range2random provider
range2random_provider=""
diff --git a/script/service-runnable b/script/service-runnable
deleted file mode 100755
index ed90c5e..0000000
--- a/script/service-runnable
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/bin/bash
-# This script is part of Booth.
-# It checks whether the given resource (service) still has a chance
-# to run on the local cluster, so that booth knows whether to
-# acquire the ticket here.
-
-service="${1:?Need a resource name as first argument.}"
-if [ -z "$service" ]; then
- ha_logger "$0: bad usage: no resource name"
- exit 1
-fi
-tmpshadow=`mktemp booth-check.XXXXXX`
-if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
- ha_logger "$0: mktemp failed"
- exit 1
-fi
-
-trap "rm -f $tmpshadow" EXIT
-
-
-# We expect an output like
-# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
-
-status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
-if [ $? -ne 0 ]; then
- ha_logger "$0: crm_simulate failed"
- ha_logger "$0: crm_simulate: $status"
- exit 1
-fi
-
-if echo "$status" |
- sed -n '/^Revised cluster status:/,$p' |
- egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
-then
- # can be started - we're done.
- exit 0
-fi
-
-# If target-role is Stopped, it judges with being stopped explicitly.
-output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
-rc=$?
-if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
- exit 0
-fi
-
-# is ticket in standby?
-output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
-rc=$?
-if [ $rc -eq 0 -a "$output" = true ]; then
- exit 0
-fi
-
-# Some error occured.
-# Try to help the admin with a bit of diagnostic.
-#
-# disallow ms-resources, ie. only primitives wanted here
-if ! crm_resource -l | grep -v ":" | grep "$service" ; then
- ha_logger "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
-fi
-
-exit 1
-
diff --git a/script/service-runnable.in b/script/service-runnable.in
new file mode 100755
index 0000000..9ea33d4
--- /dev/null
+++ b/script/service-runnable.in
@@ -0,0 +1,61 @@
+#!/bin/bash
+# This script is part of Booth.
+# It checks whether the given resource (service) still has a chance
+# to run on the local cluster, so that booth knows whether to
+# acquire the ticket here.
+
+service="${1:?Need a resource name as first argument.}"
+if [ -z "$service" ]; then
+ @LOGGER@ "$0: bad usage: no resource name"
+ exit 1
+fi
+tmpshadow=`mktemp booth-check.XXXXXX`
+if [ $? -ne 0 -o ! -f "$tmpshadow" ]; then
+ @LOGGER@ "$0: mktemp failed"
+ exit 1
+fi
+
+trap "rm -f $tmpshadow" EXIT
+
+
+# We expect an output like
+# p_dummy (ocf::pacemaker:Dummy): Started geo-rz2-a
+
+status=`crm_simulate -O $tmpshadow --ticket-grant "$BOOTH_TICKET" --simulate --live-check 2>&1`
+if [ $? -ne 0 ]; then
+ @LOGGER@ "$0: crm_simulate failed"
+ @LOGGER@ "$0: crm_simulate: $status"
+ exit 1
+fi
+
+if echo "$status" |
+ sed -n '/^Revised cluster status:/,$p' |
+ egrep "^[[:space:]]+$service[[:space:]]+\(.*\):[[:space:]]+Started ([^[:space:]]+) *$" >/dev/null
+then
+ # can be started - we're done.
+ exit 0
+fi
+
+# If target-role is Stopped, it judges with being stopped explicitly.
+output=$(crm_resource --meta --get-parameter="target-role" --resource=$service 2>/dev/null)
+rc=$?
+if [ $rc -eq 0 -a "$output" = "Stopped" ]; then
+ exit 0
+fi
+
+# is ticket in standby?
+output=$(crm_ticket --ticket "$BOOTH_TICKET" --get-attr standby)
+rc=$?
+if [ $rc -eq 0 -a "$output" = true ]; then
+ exit 0
+fi
+
+# Some error occured.
+# Try to help the admin with a bit of diagnostic.
+#
+# disallow ms-resources, ie. only primitives wanted here
+if ! crm_resource -l | grep -v ":" | grep "$service" ; then
+ @LOGGER@ "Defined resource '$service' in $BOOTH_CONF_PATH is not a primitive??"
+fi
+
+exit 1
--
2.4.11