Blame SOURCES/bz1077888-ctdb-updates.patch

261ad6
From f681e6798d3a5ead5a0e077d6e73343b266ef56f Mon Sep 17 00:00:00 2001
261ad6
From: David Vossel <dvossel@redhat.com>
261ad6
Date: Wed, 29 Apr 2015 11:18:25 -0500
261ad6
Subject: [PATCH 6/6] CTDB fixes
261ad6
261ad6
---
261ad6
 heartbeat/CTDB | 61 +++++++++++++++++++++++++++++++++++++++++++++-------------
261ad6
 1 file changed, 48 insertions(+), 13 deletions(-)
261ad6
261ad6
diff --git a/heartbeat/CTDB b/heartbeat/CTDB
261ad6
index d1e8d03..1cf9d8c 100755
261ad6
--- a/heartbeat/CTDB
261ad6
+++ b/heartbeat/CTDB
261ad6
@@ -72,6 +72,19 @@
261ad6
 #######################################################################
261ad6
 # Default parameter values:
261ad6
 
261ad6
+# Some distro's ctdb package stores the persistent db in /var/lib/ctdb,
261ad6
+# others store in /var/ctdb. This attempts to detect the correct default
261ad6
+# directory.
261ad6
+var_prefix="/var/lib/ctdb"
261ad6
+if [ ! -d "$var_prefix" ] && [ -d "/var/ctdb" ]; then
261ad6
+	var_prefix="/var/ctdb"
261ad6
+fi
261ad6
+
261ad6
+run_prefix="/run"
261ad6
+if [ ! -d "$var_prefix" ] && [ -d "/var/run" ]; then
261ad6
+	var_prefix="/var/run"
261ad6
+fi
261ad6
+
261ad6
 : ${OCF_RESKEY_ctdb_manages_samba:=no}
261ad6
 : ${OCF_RESKEY_ctdb_manages_winbind:=no}
261ad6
 : ${OCF_RESKEY_ctdb_service_smb:=""}
261ad6
@@ -84,9 +97,10 @@
261ad6
 : ${OCF_RESKEY_ctdb_config_dir:=/etc/ctdb}
261ad6
 : ${OCF_RESKEY_ctdb_binary:=/usr/bin/ctdb}
261ad6
 : ${OCF_RESKEY_ctdbd_binary:=/usr/sbin/ctdbd}
261ad6
-: ${OCF_RESKEY_ctdb_socket:=/var/lib/ctdb/ctdb.socket}
261ad6
-: ${OCF_RESKEY_ctdb_dbdir:=/var/lib/ctdb}
261ad6
+: ${OCF_RESKEY_ctdb_dbdir:=${var_prefix}}
261ad6
 : ${OCF_RESKEY_ctdb_logfile:=/var/log/ctdb/log.ctdb}
261ad6
+: ${OCF_RESKEY_ctdb_rundir:=${run_prefix}/ctdb}
261ad6
+: ${OCF_RESKEY_ctdb_socket:=${OCF_RESKEY_ctdb_rundir}/ctdbd.socket}
261ad6
 : ${OCF_RESKEY_ctdb_debuglevel:=2}
261ad6
 
261ad6
 : ${OCF_RESKEY_smb_conf:=/etc/samba/smb.conf}
261ad6
@@ -104,12 +118,13 @@ meta_data() {
261ad6
 
261ad6
 <longdesc lang="en">
261ad6
 This resource agent manages CTDB, allowing one to use Clustered Samba in a
261ad6
-Linux-HA/Pacemaker cluster.  You need a shared filesystem (e.g. OCFS2) on
261ad6
+Linux-HA/Pacemaker cluster.  You need a shared filesystem (e.g. OCFS2 or GFS2) on
261ad6
 which the CTDB lock will be stored.  Create /etc/ctdb/nodes containing a list
261ad6
 of private IP addresses of each node in the cluster, then configure this RA
261ad6
-as a clone.  To have CTDB manage Samba, set ctdb_manages_samba="yes".
261ad6
-Note that this option will be deprecated in future, in favour of configuring
261ad6
-a separate Samba resource.
261ad6
+as a clone.  This agent expects the samba and windbind resources
261ad6
+to be managed outside of CTDB's control as a separate set of resources controlled
261ad6
+by the cluster manager.  The optional support for enabling CTDB management of these
261ad6
+daemons will be depreciated.
261ad6
 
261ad6
 For more information see http://linux-ha.org/wiki/CTDB_(resource_agent)
261ad6
 </longdesc>
261ad6
@@ -235,7 +250,7 @@ Full path to the domain socket that ctdbd will create, used for
261ad6
 local clients to attach and communicate with the ctdb daemon.
261ad6
 </longdesc>
261ad6
 <shortdesc lang="en">CTDB socket location</shortdesc>
261ad6
-<content type="string" default="/var/lib/ctdb/ctdb.socket" />
261ad6
+<content type="string" default="${OCF_RESKEY_ctdb_socket}" />
261ad6
 </parameter>
261ad6
 
261ad6
 <parameter name="ctdb_dbdir" unique="1" required="0">
261ad6
@@ -244,7 +259,7 @@ The directory to put the local CTDB database files in.
261ad6
 Persistent database files will be put in ctdb_dbdir/persistent.
261ad6
 </longdesc>
261ad6
 <shortdesc lang="en">CTDB database directory</shortdesc>
261ad6
-<content type="string" default="/var/lib/ctdb" />
261ad6
+<content type="string" default="${OCF_RESKEY_ctdb_dbdir}" />
261ad6
 </parameter>
261ad6
 
261ad6
 <parameter name="ctdb_logfile" unique="0" required="0">
261ad6
@@ -256,6 +271,15 @@ value "syslog".
261ad6
 <content type="string" default="/var/log/ctdb/log.ctdb" />
261ad6
 </parameter>
261ad6
 
261ad6
+<parameter name="ctdb_rundir" unique="0" required="0">
261ad6
+<longdesc lang="en">
261ad6
+Full path to ctdb runtime directory, used for storage of socket
261ad6
+lock state.
261ad6
+</longdesc>
261ad6
+<shortdesc lang="en">CTDB runtime directory location</shortdesc>
261ad6
+<content type="string" default="${OCF_RESKEY_ctdb_rundir}" />
261ad6
+</parameter>
261ad6
+
261ad6
 <parameter name="ctdb_debuglevel" unique="0" required="0">
261ad6
 <longdesc lang="en">
261ad6
 What debug level to run at (0-10). Higher means more verbose.
261ad6
@@ -538,7 +562,16 @@ ctdb_start() {
261ad6
 
261ad6
 	# Use logfile by default, or syslog if asked for
261ad6
 	local log_option="--logfile=$OCF_RESKEY_ctdb_logfile"
261ad6
-	[ "$OCF_RESKEY_ctdb_logfile" = "syslog" ] && log_option="--syslog"
261ad6
+	if [ "$OCF_RESKEY_ctdb_logfile" = "syslog" ]; then
261ad6
+		log_option="--syslog"
261ad6
+	elif [ ! -d "$(dirname $OCF_RESKEY_ctdb_logfile)" ]; then
261ad6
+		# ensure the logfile's directory exists, otherwise ctdb will fail to start
261ad6
+		mkdir -p $(dirname $OCF_RESKEY_ctdb_logfile)
261ad6
+	fi
261ad6
+
261ad6
+	# ensure ctdb's rundir exists, otherwise it will fail to start
261ad6
+	mkdir -p $OCF_RESKEY_ctdb_rundir 2>/dev/null
261ad6
+
261ad6
 	# public addresses file (should not be present, but need to set for correctness if it is)
261ad6
 	local pub_addr_option=""
261ad6
 	[ -f "${OCF_RESKEY_ctdb_config_dir}/public_addresses" ] && \
261ad6
@@ -562,7 +595,7 @@ ctdb_start() {
261ad6
 	if [ $? -ne 0 ]; then
261ad6
 		# cleanup smb.conf
261ad6
 		cleanup_smb_conf
261ad6
-		
261ad6
+
261ad6
 		ocf_exit_reason "Failed to execute $OCF_RESKEY_ctdbd_binary."
261ad6
 		return $OCF_ERR_GENERIC
261ad6
 	else
261ad6
@@ -589,10 +622,10 @@ ctdb_start() {
261ad6
 			fi
261ad6
 		done
261ad6
 	fi
261ad6
-	
261ad6
+
261ad6
 	# ctdbd will (or can) actually still be running at this point, so kill it
261ad6
 	ctdb_stop
261ad6
-	
261ad6
+
261ad6
 	ocf_exit_reason "Timeout waiting for CTDB to stabilize"
261ad6
 	return $OCF_ERR_GENERIC
261ad6
 }
261ad6
@@ -601,7 +634,7 @@ ctdb_start() {
261ad6
 ctdb_stop() {
261ad6
 	# Do nothing if already stopped
261ad6
 	pkill -0 -f $OCF_RESKEY_ctdbd_binary || return $OCF_SUCCESS
261ad6
-	
261ad6
+
261ad6
 	# Tell it to die nicely
261ad6
 	invoke_ctdb shutdown >/dev/null 2>&1
261ad6
 	rv=$?
261ad6
@@ -645,6 +678,8 @@ ctdb_monitor() {
261ad6
 	if [ $? -ne 0 ]; then
261ad6
 		if echo $status | grep -qs 'Connection refused'; then
261ad6
 			return $OCF_NOT_RUNNING
261ad6
+		elif echo $status | grep -qs 'No such file or directory'; then
261ad6
+			return $OCF_NOT_RUNNING
261ad6
 		else
261ad6
 			ocf_exit_reason "CTDB status call failed: $status"
261ad6
 			return $OCF_ERR_GENERIC
261ad6
-- 
261ad6
1.8.4.2
261ad6