[SCM] CTDB repository - branch master updated - ctdb-2.0-52-g50abf59

Amitay Isaacs amitay at samba.org
Mon Jan 7 23:02:32 MST 2013


The branch, master has been updated
       via  50abf597cefe6f8ea2a2ff7694bf84641344a9b1 (commit)
       via  e2aaa64925cca359c71520e01a18fc9461b0da4d (commit)
       via  03356fd5ae7a3ac35fde0289cbea7c71ecf07367 (commit)
       via  13e5e609b262847b607e7af7e0685f44e7cb8e36 (commit)
       via  8507303b525d20c74e8ec4e7c4f5f275945cd3b6 (commit)
       via  376015ba5ad6b7703ae9949a1d40a0c72dfaba0c (commit)
       via  740ea8ea5084149c8b552a01ee1c98c558b12384 (commit)
       via  b23c30253cc9eb274b895cac0f8c65245ba0a200 (commit)
      from  13a5944f8a27d43006acfffba76958693cae7702 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 50abf597cefe6f8ea2a2ff7694bf84641344a9b1
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 4 13:52:01 2013 +1100

    scripts: Make script_log() use supplied message, stop logger from hanging
    
    When using syslog any provided message arguments are ignored and not
    passed to logger.  This means that logger blocks waiting on stdin.
    That's bad.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit e2aaa64925cca359c71520e01a18fc9461b0da4d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 4 11:41:03 2013 +1100

    scripts: Rework ctdb-crash-cleanup.sh so that it uses existing functions
    
    This improves maintainability.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 03356fd5ae7a3ac35fde0289cbea7c71ecf07367
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jan 4 11:23:29 2013 +1100

    scripts: Make drop_all_public_ips() more robust
    
    Incorporate some of the logic from ctdb-crash-cleanup.sh that ensures
    IPs are deleted even if they have the wrong netmask or are on the
    wrong interface.
    
    Factoring out some of the code will allow it to be used elsewhere.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 13e5e609b262847b607e7af7e0685f44e7cb8e36
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 3 16:02:52 2013 +1100

    ctdbd: Default value for debug_hung_script should use ETCDIR
    
    That is, it should use whatever was specified in ./configure and
    should not hardcode /etc.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 8507303b525d20c74e8ec4e7c4f5f275945cd3b6
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 3 15:33:57 2013 +1100

    scripts: debug-hung-script.sh doesn't need functions/loadconfig
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 376015ba5ad6b7703ae9949a1d40a0c72dfaba0c
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 3 15:33:10 2013 +1100

    scripts: statd-callout should calculate CTDB_BASE if it is not set
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 740ea8ea5084149c8b552a01ee1c98c558b12384
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 3 15:26:12 2013 +1100

    eventscripts: Each script should set CTDB_BASE if it is not set
    
    This makes it easier to run the scripts externally.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit b23c30253cc9eb274b895cac0f8c65245ba0a200
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 3 15:07:07 2013 +1100

    scripts: Move drop_all_public_ips() to the functions file
    
    ... so it can be improved and used elsewhere.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 config/ctdb-crash-cleanup.sh      |   49 +++++++++++++------------------------
 config/ctdb.init                  |    6 ----
 config/debug-hung-script.sh       |    3 --
 config/events.d/00.ctdb           |    3 ++
 config/events.d/01.reclock        |    3 ++
 config/events.d/10.interface      |    3 ++
 config/events.d/11.natgw          |    3 ++
 config/events.d/11.routing        |    3 ++
 config/events.d/13.per_ip_routing |    3 ++
 config/events.d/20.multipathd     |    3 ++
 config/events.d/31.clamd          |    3 ++
 config/events.d/40.fs_use         |    3 ++
 config/events.d/40.vsftpd         |    3 ++
 config/events.d/41.httpd          |    3 ++
 config/events.d/49.winbind        |    3 ++
 config/events.d/50.samba          |    3 ++
 config/events.d/60.ganesha        |    3 ++
 config/events.d/60.nfs            |    3 ++
 config/events.d/62.cnfs           |    3 ++
 config/events.d/70.iscsi          |    3 ++
 config/events.d/91.lvs            |    3 ++
 config/events.d/99.timeout        |    3 ++
 config/functions                  |   37 +++++++++++++++++++++++++++-
 config/statd-callout              |    5 +--
 server/ctdbd.c                    |    2 +-
 25 files changed, 113 insertions(+), 46 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/ctdb-crash-cleanup.sh b/config/ctdb-crash-cleanup.sh
index e176518..f426056 100755
--- a/config/ctdb-crash-cleanup.sh
+++ b/config/ctdb-crash-cleanup.sh
@@ -4,41 +4,26 @@
 # all public ip addresses if CTDBD has crashed or stopped running.
 #
 
-[ -z "$CTDB_BASE" ] && {
-    CTDB_BASE=/etc/ctdb
-}
+# If ctdb is running, just exit
+if ctdb ping >/dev/null 2>&1 ; then
+    exit 0
+fi
 
-[ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
-	CTDB_PUBLIC_ADDRESSES=$CTDB_BASE/public_addresses
-}
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
 
-[ ! -f "$CTDB_PUBLIC_ADDRESSES" ] && {
-	echo "No public addresses file found. Can't clean up."
-	exit 1
-}
+. "$CTDB_BASE/functions"
 
-# if ctdb is running, just return
-ctdb status 2>/dev/null && {
-    exit 0
-}
-
-if [ -f /etc/sysconfig/ctdb ]; then
-    CTDB_CONFIG=/etc/sysconfig/ctdb
-elif [ -f /etc/default/ctdb ]; then
-    CTDB_CONFIG=/etc/default/ctdb
-else
-    echo "CTDB config not found. Can't clean up."
-    exit 1
-fi
+loadconfig ctdb
+
+[ -n "$CTDB_PUBLIC_ADDRESSES" ] || \
+	CTDB_PUBLIC_ADDRESSES="$CTDB_BASE/public_addresses"
 
-(cat $CTDB_CONFIG | egrep "^CTDB_NATGW_PUBLIC_IP" | sed -e "s/.*=//" -e "s/\/.*//";cat "$CTDB_PUBLIC_ADDRESSES" | cut -d/ -f1) | while read _IP; do
-	_IP_HELD=`/sbin/ip addr show | grep "inet $_IP/"`
-	[ -z "$_IP_HELD" ] || {
-		_IFACE=`echo $_IP_HELD | sed -e "s/.*\s//"`
-		_NM=`echo $_IP_HELD | sed -e "s/.*$_IP\///" -e "s/\s.*//"`
-		logger "Removing public address $_IP/$_NM from device $_IFACE"
-		/sbin/ip addr del $_IP/$_NM dev $_IFACE
-	}
-done
+[ -f "$CTDB_PUBLIC_ADDRESSES" ] || \
+    die "No public addresses file found. Can't clean up."
 
+drop_all_public_ips "ctdb-crash-cleanup"
 
+if [ -n "$CTDB_NATGW_PUBLIC_IP" ] ; then
+    drop_ip "$CTDB_NATGW_PUBLIC_IP" "ctdb-crash-cleanup"
+fi
diff --git a/config/ctdb.init b/config/ctdb.init
index 85c1728..9f9b686 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -219,12 +219,6 @@ wait_until_ready () {
 
 ctdbd=${CTDBD:-/usr/sbin/ctdbd}
 
-drop_all_public_ips() {
-    while read _ip _iface _rest; do
-	ip addr del $_ip dev $_iface >/dev/null 2>&1
-    done <"${CTDB_PUBLIC_ADDRESSES:-/dev/null}"
-}
-
 start() {
     echo -n $"Starting ctdbd service: "
 
diff --git a/config/debug-hung-script.sh b/config/debug-hung-script.sh
index d468cc6..dcf68ba 100644
--- a/config/debug-hung-script.sh
+++ b/config/debug-hung-script.sh
@@ -1,7 +1,4 @@
 #!/bin/sh
 
-. $CTDB_BASE/functions
-loadconfig
-
 echo "Pstree output for the hung script:"
 pstree -p -a $1
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 2f2116d..847805b 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -9,6 +9,9 @@
 #     releaseip  : called when an IP address is released
 #     recovered  : called when ctdb has finished a recovery event
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/01.reclock b/config/events.d/01.reclock
index 345a631..a3bfc66 100755
--- a/config/events.d/01.reclock
+++ b/config/events.d/01.reclock
@@ -1,6 +1,9 @@
 #!/bin/sh
 # script to check accessibility to the reclock file on a node
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/10.interface b/config/events.d/10.interface
index 7a85892..caff9fa 100755
--- a/config/events.d/10.interface
+++ b/config/events.d/10.interface
@@ -5,6 +5,9 @@
 # this adds/removes IPs from your 
 # public interface
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index 30b8c70..12ba9ca 100755
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -5,6 +5,9 @@
 # available.
 #
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/11.routing b/config/events.d/11.routing
index 38a0258..f3e972b 100755
--- a/config/events.d/11.routing
+++ b/config/events.d/11.routing
@@ -12,6 +12,9 @@
 # Example
 # bond1 10.3.3.0/24 10.0.0.1
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/13.per_ip_routing b/config/events.d/13.per_ip_routing
index d51d309..fe97ffc 100755
--- a/config/events.d/13.per_ip_routing
+++ b/config/events.d/13.per_ip_routing
@@ -1,5 +1,8 @@
 #!/bin/sh
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/20.multipathd b/config/events.d/20.multipathd
index 1bf7070..c2956d2 100755
--- a/config/events.d/20.multipathd
+++ b/config/events.d/20.multipathd
@@ -6,6 +6,9 @@
 #   CTDB_MONITOR_MPDEVICES="device1 device2 ..."
 #
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 service_name="multipathd"
diff --git a/config/events.d/31.clamd b/config/events.d/31.clamd
index 53739e2..15751a9 100755
--- a/config/events.d/31.clamd
+++ b/config/events.d/31.clamd
@@ -1,6 +1,9 @@
 #!/bin/sh
 # event script to manage clamd in a cluster environment
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 detect_init_style
diff --git a/config/events.d/40.fs_use b/config/events.d/40.fs_use
index 7dd4cc3..603b463 100644
--- a/config/events.d/40.fs_use
+++ b/config/events.d/40.fs_use
@@ -1,6 +1,9 @@
 #!/bin/sh
 # ctdb event script for checking local file system utilization
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig
 
diff --git a/config/events.d/40.vsftpd b/config/events.d/40.vsftpd
index ab23a80..25964b8 100755
--- a/config/events.d/40.vsftpd
+++ b/config/events.d/40.vsftpd
@@ -1,6 +1,9 @@
 #!/bin/sh
 # event strict to manage vsftpd in a cluster environment
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 service_name="vsftpd"
diff --git a/config/events.d/41.httpd b/config/events.d/41.httpd
index 4fb6aa0..3baa784 100755
--- a/config/events.d/41.httpd
+++ b/config/events.d/41.httpd
@@ -1,6 +1,9 @@
 #!/bin/sh
 # event script to manage httpd in a cluster environment
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 detect_init_style
diff --git a/config/events.d/49.winbind b/config/events.d/49.winbind
index cd360a9..d0a154d 100755
--- a/config/events.d/49.winbind
+++ b/config/events.d/49.winbind
@@ -1,6 +1,9 @@
 #!/bin/sh
 # ctdb event script for winbind
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 detect_init_style
diff --git a/config/events.d/50.samba b/config/events.d/50.samba
index 3a43bbe..ecbe05e 100755
--- a/config/events.d/50.samba
+++ b/config/events.d/50.samba
@@ -1,6 +1,9 @@
 #!/bin/sh
 # ctdb event script for Samba
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 detect_init_style
diff --git a/config/events.d/60.ganesha b/config/events.d/60.ganesha
index a685013..4d8736e 100755
--- a/config/events.d/60.ganesha
+++ b/config/events.d/60.ganesha
@@ -1,6 +1,9 @@
 #!/bin/sh
 # script to manage nfs in a clustered environment
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 service_name="nfs-ganesha-gpfs"
diff --git a/config/events.d/60.nfs b/config/events.d/60.nfs
index 69a99dc..2cba9a7 100755
--- a/config/events.d/60.nfs
+++ b/config/events.d/60.nfs
@@ -1,6 +1,9 @@
 #!/bin/sh
 # script to manage nfs in a clustered environment
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 service_name="nfs"
diff --git a/config/events.d/62.cnfs b/config/events.d/62.cnfs
index 3cc56e3..302b497 100755
--- a/config/events.d/62.cnfs
+++ b/config/events.d/62.cnfs
@@ -1,6 +1,9 @@
 #!/bin/sh
 # event script to integrate with gpfs cnfs
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 loadconfig
diff --git a/config/events.d/70.iscsi b/config/events.d/70.iscsi
index a050259..6b588b5 100755
--- a/config/events.d/70.iscsi
+++ b/config/events.d/70.iscsi
@@ -1,6 +1,9 @@
 #!/bin/sh
 # ctdb event script for TGTD based iSCSI
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 service_name="iscsi"
diff --git a/config/events.d/91.lvs b/config/events.d/91.lvs
index beba98d..c1e6d15 100755
--- a/config/events.d/91.lvs
+++ b/config/events.d/91.lvs
@@ -1,6 +1,9 @@
 #!/bin/sh
 # script to manage the lvs ip multiplexer for a single public address cluster
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 
 loadconfig ctdb
diff --git a/config/events.d/99.timeout b/config/events.d/99.timeout
index 7a47c8d..258366a 100755
--- a/config/events.d/99.timeout
+++ b/config/events.d/99.timeout
@@ -4,6 +4,9 @@
 # in the monitor action. The purpose is to trigger
 # the event timeout mechanism.
 
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
+
 . $CTDB_BASE/functions
 loadconfig ctdb
 
diff --git a/config/functions b/config/functions
index 330d057..8fbc079 100755
--- a/config/functions
+++ b/config/functions
@@ -110,7 +110,7 @@ script_log ()
     esac
 
     if $_using_syslog ; then
-	logger -t "$_tag"
+	logger -t "$_tag" "$*"
     else
 	{
 	    if [ -n "$*" ] ; then
@@ -939,6 +939,41 @@ delete_ip_from_iface()
     # and doing anything here will affect the return code.
 }
 
+# If the given IP is hosted then print 2 items: maskbits and iface 
+ip_maskbits_iface ()
+{
+    _addr="$1"
+
+    ip addr show to "${_addr}/32" 2>/dev/null | \
+	awk '$1 == "inet" { print gensub(".*/", "", 1, $2), $NF }'
+}
+
+drop_ip ()
+{
+    _addr="${1%/*}"  # Remove optional maskbits
+    _log_tag="$2"
+
+    set -- $(ip_maskbits_iface $_addr)
+    if [ -n "$1" ] ; then
+	_maskbits="$1"
+	_iface="$2"
+	if [ -n "$_log_tag" ] ; then
+	    script_log "$_log_tag" \
+		"Removing public address $_addr/$_maskbits from device $_iface"
+	fi
+	ip addr del $_addr/$_maskbits dev $_iface >/dev/null 2>&1
+    fi
+}
+
+drop_all_public_ips ()
+{
+    _log_tag="$1"
+
+    while read _ip _x ; do
+	drop_ip "$_ip" "$_log_tag"
+    done <"${CTDB_PUBLIC_ADDRESSES:-/dev/null}"
+}
+
 ########################################################
 # some simple logic for counting events - per eventscript
 # usage: ctdb_counter_init
diff --git a/config/statd-callout b/config/statd-callout
index 0e52cba..72a2ca9 100755
--- a/config/statd-callout
+++ b/config/statd-callout
@@ -5,9 +5,8 @@
 # /etc/sysconfig/nfs:
 #   STATD_HOSTNAME="myhostname -H /etc/ctdb/statd-callout"
 
-[ -z "$CTDB_BASE" ] && {
-    export CTDB_BASE="/etc/ctdb"
-}
+[ -n "$CTDB_BASE" ] || \
+    export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
 
 . $CTDB_BASE/functions
 loadconfig ctdb
diff --git a/server/ctdbd.c b/server/ctdbd.c
index 491b4a2..ad1baac 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -61,7 +61,7 @@ static struct {
 	.db_dir_persistent = VARDIR "/ctdb/persistent",
 	.db_dir_state = VARDIR "/ctdb/state",
 	.script_log_level = DEBUG_ERR,
-	.debug_hung_script = "/etc/ctdb/debug-hung-script.sh",
+	.debug_hung_script = ETCDIR "/ctdb/debug-hung-script.sh",
 };
 
 int script_log_level;


-- 
CTDB repository


More information about the samba-cvs mailing list