From: Martin Schwenke Date: Tue, 20 Feb 2018 07:22:33 +0000 (+1100) Subject: ctdb-scripts: Tunables are now loaded from ctdb.tunables X-Git-Tag: talloc-2.1.13~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=02fc52d69b2f74bb35150ddcec405c81da81f81f;p=thirdparty%2Fsamba.git ctdb-scripts: Tunables are now loaded from ctdb.tunables Using CTDB_SET_TunableVariables in the main configuration file is no longer supported. The only subtlety is an unexpected order change in one of the unit test results. This is because the old implementation implicitly sorted the tunable variables via the set command. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/config/ctdb.tunables b/ctdb/config/ctdb.tunables new file mode 100644 index 00000000000..b99e5cd59f6 --- /dev/null +++ b/ctdb/config/ctdb.tunables @@ -0,0 +1,2 @@ +# Set some CTDB tunable variables during CTDB startup? +# MutexEnabled=0 diff --git a/ctdb/config/ctdbd.conf b/ctdb/config/ctdbd.conf index 2399a8ec97a..3fe5c8285d2 100644 --- a/ctdb/config/ctdbd.conf +++ b/ctdb/config/ctdbd.conf @@ -21,6 +21,3 @@ # Default log level is NOTICE. Want less logging? # CTDB_DEBUGLEVEL=ERR - -# Set some CTDB tunable variables during CTDB startup? -# CTDB_SET_TDBMutexEnabled=0 diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index ee8956758b2..532f78b5132 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -105,18 +105,23 @@ EOF set_ctdb_variables () { - # set any tunables from the config file - set | sed -n '/^CTDB_SET_/s/=.*//p' | - while read v; do - varname="${v#CTDB_SET_}" - value=$(eval echo "\$$v") - if $CTDB setvar "$varname" "$value" ; then - echo "Set $varname to $value" - else - echo "Invalid configuration: CTDB_SET_${varname}=${value}" - return 1 + _f="${CTDB_BASE}/ctdb.tunables" + if [ ! -r "$_f" ] ; then + return fi - done + + while IFS="=" read _var _val ; do + case "$_var" in + \#*|"") continue ;; + esac + + if $CTDB setvar "$_var" "$_val" ; then + echo "Set $_var to $_val" + else + echo "Invalid tunable: ${_var}=${_val}" + return 1 + fi + done <"$_f" } ############################################################ diff --git a/ctdb/config/events.d/README b/ctdb/config/events.d/README index 7025a4b4432..f13714a7a2e 100644 --- a/ctdb/config/events.d/README +++ b/ctdb/config/events.d/README @@ -51,8 +51,7 @@ setup Failure of this event will cause CTDB to terminate. - Example: 00.ctdb processes tunables defined in the CTDB - configuration using CTDB_SET_=. + Example: 00.ctdb processes tunables defined in ctdb.tunables. startup diff --git a/ctdb/doc/ctdb-tunables.7.xml b/ctdb/doc/ctdb-tunables.7.xml index 7b059b75a9e..bc4e1b27edf 100644 --- a/ctdb/doc/ctdb-tunables.7.xml +++ b/ctdb/doc/ctdb-tunables.7.xml @@ -38,7 +38,25 @@ - The tunable variables are listed alphabetically. + Tunables can be set at startup from the + /usr/local/etc/ctdb/ctdb.tunables + configuration file. + + +TUNABLE=VALUE + + + + + For example: + + +MonitorInterval=20 + + + + + The available tunable variables are listed alphabetically below. @@ -743,6 +761,14 @@ + + FILES> + + + /usr/local/etc/ctdb/ctdb.tunables + + + SEE ALSO diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml index 862370e13be..05d12315464 100644 --- a/ctdb/doc/ctdbd.conf.5.xml +++ b/ctdb/doc/ctdbd.conf.5.xml @@ -1428,31 +1428,6 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000 - - - TUNABLES CONFIGURATION - - - - CTDB tunables (see - ctdbd-tunables - 7) can be set from the - configuration file. They are set as follows: - - -CTDB_SET_TUNABLE=VALUE - - - - - For example: - - -CTDB_SET_MonitorInterval=20 - - - - DEBUG AND TEST diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in index 4ef3dcf871a..80247fc2315 100644 --- a/ctdb/packaging/RPM/ctdb.spec.in +++ b/ctdb/packaging/RPM/ctdb.spec.in @@ -114,6 +114,7 @@ mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sudoers.d DESTDIR=$RPM_BUILD_ROOT ./buildtools/bin/waf install install -m644 config/ctdbd.conf $RPM_BUILD_ROOT%{_sysconfdir}/ctdb +install -m644 config/ctdb.tunables $RPM_BUILD_ROOT%{_sysconfdir}/ctdb # Add a pointer to modern location for configuration file. Allow with # "noreplace" in the files section, this stops RPM moving aside a @@ -154,6 +155,7 @@ rm -rf $RPM_BUILD_ROOT %defattr(-,root,root) %config(noreplace) %{_sysconfdir}/ctdb/ctdbd.conf +%config(noreplace) %{_sysconfdir}/ctdb/ctdb.tunables %config(noreplace) %{_sysconfdir}/ctdb/notify.sh %config(noreplace) %{_sysconfdir}/ctdb/debug-hung-script.sh %config(noreplace) %{_sysconfdir}/ctdb/ctdb-crash-cleanup.sh diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.003.sh b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh index 6b76ce9ff64..7a82b254b24 100755 --- a/ctdb/tests/eventscripts/00.ctdb.setup.003.sh +++ b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh @@ -14,7 +14,7 @@ EOF required_result 1 <<EOF Set MonitorInterval to 5 Unable to set tunable variable 'UnknownMagic' -Invalid configuration: CTDB_SET_UnknownMagic=0 +Invalid tunable: UnknownMagic=0 Aborting setup due to invalid configuration - fix typos, remove unknown tunables EOF diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.004.sh b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh index eebf93b2534..b10865ce884 100755 --- a/ctdb/tests/eventscripts/00.ctdb.setup.004.sh +++ b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh @@ -12,9 +12,9 @@ EventScriptUnhealthyOnTimeout=0 EOF required_result 0 <<EOF +Set MonitorInterval to 5 Setting obsolete tunable variable 'EventScriptUnhealthyOnTimeout' Set EventScriptUnhealthyOnTimeout to 0 -Set MonitorInterval to 5 EOF simple_test diff --git a/ctdb/tests/eventscripts/etc/sysconfig/ctdb b/ctdb/tests/eventscripts/etc/sysconfig/ctdb index e03d8103827..9a20319731a 100644 --- a/ctdb/tests/eventscripts/etc/sysconfig/ctdb +++ b/ctdb/tests/eventscripts/etc/sysconfig/ctdb @@ -1,5 +1 @@ CTDB_DEBUGLEVEL=ERR - -if [ -n "$FAKE_CTDB_EXTRA_CONFIG" -a -r "$FAKE_CTDB_EXTRA_CONFIG" ] ; then - . "$FAKE_CTDB_EXTRA_CONFIG" -fi diff --git a/ctdb/tests/eventscripts/scripts/00.ctdb.sh b/ctdb/tests/eventscripts/scripts/00.ctdb.sh index c17634984e8..7dd654e8cd0 100644 --- a/ctdb/tests/eventscripts/scripts/00.ctdb.sh +++ b/ctdb/tests/eventscripts/scripts/00.ctdb.sh @@ -18,16 +18,7 @@ setup () setup_tunable_config () { - _t="${EVENTSCRIPTS_TESTS_VAR_DIR}/fake-tunable-config.sh" - export FAKE_CTDB_EXTRA_CONFIG="$_t" - rm -f "$FAKE_CTDB_EXTRA_CONFIG" - - while read line ; do - case "$line" in - \#*|"") : ;; - *) echo "CTDB_SET_${line}" - esac - done >"$FAKE_CTDB_EXTRA_CONFIG" + cat >"${CTDB_BASE}/ctdb.tunables" } result_filter ()