mirror of
https://github.com/samba-team/samba.git
synced 2025-03-22 02:50:28 +03:00
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)
This commit is contained in:
parent
ffc43bee4d
commit
ce210f6978
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user