ctdb-scripts: Tunables are now loaded from ctdb.tunables
authorMartin Schwenke <martin@meltin.net>
Tue, 20 Feb 2018 07:22:33 +0000 (18:22 +1100)
committerAmitay Isaacs <amitay@samba.org>
Wed, 28 Mar 2018 00:57:21 +0000 (02:57 +0200)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/config/ctdb.tunables [new file with mode: 0644]
ctdb/config/ctdbd.conf
ctdb/config/events.d/00.ctdb
ctdb/config/events.d/README
ctdb/doc/ctdb-tunables.7.xml
ctdb/doc/ctdbd.conf.5.xml
ctdb/packaging/RPM/ctdb.spec.in
ctdb/tests/eventscripts/00.ctdb.setup.003.sh
ctdb/tests/eventscripts/00.ctdb.setup.004.sh
ctdb/tests/eventscripts/etc/sysconfig/ctdb
ctdb/tests/eventscripts/scripts/00.ctdb.sh

diff --git a/ctdb/config/ctdb.tunables b/ctdb/config/ctdb.tunables
new file mode 100644 (file)
index 0000000..b99e5cd
--- /dev/null
@@ -0,0 +1,2 @@
+# Set some CTDB tunable variables during CTDB startup?
+# MutexEnabled=0
index 2399a8ec97a0cd5624a09edc6120f8dbd6cb410d..3fe5c8285d2a44a0f7a625123081aea4f450cfb6 100644 (file)
@@ -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
index ee8956758b257564f641dd7ab96662ad84b4938f..532f78b5132e6907518ab50e5c0a71e8a7b6e79f 100755 (executable)
@@ -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"
 }
 
 ############################################################
index 7025a4b44324c99a50e311393c5d797ca3ff8a17..f13714a7a2eddd82ce1e2f35fdfafb14fb4bec1f 100644 (file)
@@ -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_<TunableName>=<TunableValue>.
+       Example: 00.ctdb processes tunables defined in ctdb.tunables.
 
 startup
 
index 7b059b75a9e1d079a907931d0eac24bc43d75bb4..bc4e1b27edff93a18e701cba5167df98fea1ba59 100644 (file)
     </para>
 
     <para>
-      The tunable variables are listed alphabetically.
+      Tunables can be set at startup from the
+      <filename>/usr/local/etc/ctdb/ctdb.tunables</filename>
+      configuration file.
+
+      <literallayout>
+<replaceable>TUNABLE</replaceable>=<replaceable>VALUE</replaceable>
+      </literallayout>
+    </para>
+
+    <para>
+      For example:
+
+      <screen format="linespecific">
+MonitorInterval=20
+      </screen>
+    </para>
+
+    <para>
+      The available tunable variables are listed alphabetically below.
     </para>
 
     <refsect2>
 
   </refsect1>
 
+  <refsect1>
+    <title>FILES></title>
+
+    <simplelist>
+      <member><filename>/usr/local/etc/ctdb/ctdb.tunables</filename></member>
+    </simplelist>
+  </refsect1>
+
   <refsect1>
     <title>SEE ALSO</title>
     <para>
index 862370e13be39a6a15f8dc3093229dab2894d689..05d12315464ba0b01095135dcf20a8bf7cc20895 100644 (file)
@@ -1428,31 +1428,6 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
 
   </refsect1>
 
-  <refsect1>
-    <title>
-      TUNABLES CONFIGURATION
-    </title>
-
-    <para>
-      CTDB tunables (see
-      <citerefentry><refentrytitle>ctdbd-tunables</refentrytitle>
-      <manvolnum>7</manvolnum></citerefentry>) can be set from the
-      configuration file.  They are set as follows:
-
-      <literallayout>
-CTDB_SET_<replaceable>TUNABLE</replaceable>=<replaceable>VALUE</replaceable>
-      </literallayout>
-    </para>
-
-    <para>
-      For example:
-
-      <screen format="linespecific">
-CTDB_SET_MonitorInterval=20
-      </screen>
-    </para>
-  </refsect1>
-
   <refsect1>
     <title>
       DEBUG AND TEST
index 4ef3dcf871ab07acbadcc682ea201fbea3b33280..80247fc2315d3d712fd3601377962940d665d6ba 100644 (file)
@@ -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
index 6b76ce9ff6462c219fd5f028f2b9924b12e6d1f3..7a82b254b24819c3d34d9d5f72d47e17070bfb07 100755 (executable)
@@ -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
 
index eebf93b2534f3223f7868b3679dac88157989843..b10865ce884bc62e9f102c08465d21fba98a4686 100755 (executable)
@@ -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
index e03d8103827fb3c429530aca85b85d0e42d1ec16..9a20319731abe8ccca5a742b2f13ee9be740fb75 100644 (file)
@@ -1,5 +1 @@
 CTDB_DEBUGLEVEL=ERR
-
-if [ -n "$FAKE_CTDB_EXTRA_CONFIG" -a -r "$FAKE_CTDB_EXTRA_CONFIG" ] ; then
-   . "$FAKE_CTDB_EXTRA_CONFIG"
-fi
index c17634984e837b09912db7fb6088b42eee94973d..7dd654e8cd0f97fb01d7aa80fad9d3b6de4e194e 100644 (file)
@@ -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 ()