]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-server: Load optional tunables.d/ directory
authorMartin Schwenke <mschwenke@ddn.com>
Wed, 25 Jun 2025 12:18:16 +0000 (22:18 +1000)
committerMartin Schwenke <martins@samba.org>
Wed, 23 Jul 2025 00:02:47 +0000 (00:02 +0000)
Change the variable name to "path" so it makes sense to reuse it for
the directory.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Jul 23 00:02:47 UTC 2025 on atb-devel-224

ctdb/doc/ctdb-tunables.7.xml
ctdb/server/ctdb_tunables.c

index 766213e14231836958204db3c8996f1c869e0b3c..56b1e055a84628380e88d86804557ead9de0c8ff 100644 (file)
     </para>
 
     <para>
-      Tunables can be set at startup from the
-      <filename>/usr/local/etc/ctdb/ctdb.tunables</filename>
-      configuration file.
+      Tunables can be set at startup via optional configuration files.
+      First, <filename>/usr/local/etc/ctdb/ctdb.tunables</filename> is
+      loaded, if this file exists.  After this, all files with names
+      matching <filename>*.tunables</filename> in directory
+      <filename>/usr/local/etc/ctdb/tunables.d/</filename> are loaded
+      in the current locale's collation order, if the directory
+      exists.
+    </para>
+
+    <para>
+      The format of lines in tunables files is:
 
       <literallayout>
 <replaceable>TUNABLE</replaceable>=<replaceable>VALUE</replaceable>
@@ -722,6 +730,7 @@ MonitorInterval=20
 
     <simplelist>
       <member><filename>/usr/local/etc/ctdb/ctdb.tunables</filename></member>
+      <member><filename>/usr/local/etc/ctdb/tunables.d/*.tunables</filename></member>
     </simplelist>
   </refsect1>
 
index 180e2849a21d07c1b3aff65b2616611a38fd3983..66c4d2d645bc654ae88fee1f2f6a0d066817587c 100644 (file)
@@ -142,12 +142,10 @@ int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata)
 
 bool ctdb_tunables_load(struct ctdb_context *ctdb)
 {
-       bool status;
+       bool status = false; /* fail by default */
+       bool dir_status = false;
        TALLOC_CTX *tmp_ctx;
-       char *file = NULL;
-
-       /* Fail by default */
-       status = false;
+       char *path = NULL;
 
        tmp_ctx = talloc_new(ctdb);
        if (tmp_ctx == NULL) {
@@ -157,15 +155,33 @@ bool ctdb_tunables_load(struct ctdb_context *ctdb)
 
        ctdb_tunable_set_defaults(&ctdb->tunable);
 
-       file = path_etcdir_append(tmp_ctx, "ctdb.tunables");
-       if (file == NULL) {
+       path = path_etcdir_append(tmp_ctx, "ctdb.tunables");
+       if (path == NULL) {
                D_ERR("Failed to construct path for ctdb.tunables\n");
                goto done;
        }
 
-       status = ctdb_tunable_load_file(tmp_ctx, &ctdb->tunable, file);
-       /* No need to log error, already logged above */
+       status = ctdb_tunable_load_file(tmp_ctx, &ctdb->tunable, path);
+
+       /*
+        * Continue loading directory on failure to avoid forcing a
+        * typo-prone admin to play whack-a-mole.  Final result is
+        * still failure.
+        */
 
+       /* Avoid talloc confusion in static analysers... */
+       talloc_free(path);
+
+       path = path_etcdir_append(tmp_ctx, "tunables.d");
+       if (path == NULL) {
+               D_ERR("Failed to construct path for tunables.d\n");
+               goto done;
+       }
+
+       dir_status = ctdb_tunable_load_directory(tmp_ctx, &ctdb->tunable, path);
+       if (!dir_status) {
+               status = false;
+       }
 done:
        talloc_free(tmp_ctx);
        return status;