summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2012-09-03 12:39:36 +1000
committerAmitay Isaacs <amitay@gmail.com>2012-10-17 11:32:41 +1100
commitce210f697840a0869a0ae4015d1086cc32486ff6 (patch)
tree0ff93065c10eb4ba4cd4bea907ca0ae140f32fff
parentffc43bee4dae578f11eac630af13bf05a1a5b7ce (diff)
downloadsamba-ce210f697840a0869a0ae4015d1086cc32486ff6.tar.gz
samba-ce210f697840a0869a0ae4015d1086cc32486ff6.tar.xz
samba-ce210f697840a0869a0ae4015d1086cc32486ff6.zip
scripts: Remove duplicate code from init script to set tunables
The tunable variables defined in CTDB configuration file are currently set up from init script as well as part of "setup" event in 00.ctdb eventscript. Remove the duplication of this code and set tunable variables only from setup event. During the "setup" event, it's possible that ctdb tool commands can timeout if CTDB daemon is not ready. To guard against such eventuality, wait till "ctdb ping" command succeeds before executing any other ctdb tool commands. Signed-off-by: Amitay Isaacs <amitay@gmail.com> (This used to be ctdb commit 632c1b9c1cc2e242376358ce49fd2022b3f27aa2)
-rwxr-xr-xctdb/config/ctdb.init14
-rwxr-xr-xctdb/config/events.d/00.ctdb37
2 files changed, 30 insertions, 21 deletions
diff --git a/ctdb/config/ctdb.init b/ctdb/config/ctdb.init
index 581844d34c..372affba71 100755
--- a/ctdb/config/ctdb.init
+++ b/ctdb/config/ctdb.init
@@ -214,16 +214,6 @@ EOF
done
}
-set_ctdb_variables () {
- # set any tunables from the config file
- set | grep ^CTDB_SET_ | cut -d_ -f3- |
- while read v; do
- varname=`echo $v | cut -d= -f1`
- value=`echo $v | cut -d= -f2`
- ctdb setvar $varname $value || RETVAL=1
- done || exit 1
-}
-
set_retval() {
return $1
}
@@ -304,9 +294,7 @@ start() {
esac
if [ $RETVAL -eq 0 ] ; then
- if wait_until_ready ; then
- set_ctdb_variables
- else
+ if ! wait_until_ready ; then
RETVAL=1
pkill -9 -f $ctdbd >/dev/null 2>&1
fi
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 2a48afb8e2..2f2116d061 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -35,6 +35,30 @@ update_config_from_tdb() {
fi
}
+set_ctdb_variables () {
+ # set any tunables from the config file
+ set | grep ^CTDB_SET_ | cut -d_ -f3- |
+ while read v; do
+ varname=`echo $v | cut -d= -f1`
+ value=`echo $v | cut -d= -f2`
+ ctdb setvar $varname $value || return 1
+ echo "Set $varname to $value"
+ done
+}
+
+wait_until_ready () {
+ _timeout="${1:-10}" # default is 10 seconds
+
+ _count=0
+ while ! ctdb ping >/dev/null 2>&1 ; do
+ if [ $_count -ge $_timeout ] ; then
+ return 1
+ fi
+ sleep 1
+ _count=$(($_count + 1))
+ done
+}
+
ctdb_check_args "$@"
case "$1" in
@@ -51,14 +75,11 @@ case "$1" in
;;
setup)
- # set any tunables from the config file
- set | grep ^CTDB_SET_ | cut -d_ -f3- |
- while read v; do
- varname=`echo $v | cut -d= -f1`
- value=`echo $v | cut -d= -f2`
- ctdb setvar $varname $value || exit 1
- echo "Set $varname to $value"
- done || exit 1
+ # Make sure CTDB daemon is ready to process requests
+ if wait_until_ready ; then
+ # set any tunables from the config file
+ set_ctdb_variables
+ fi || exit 1
;;
startup)