]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-conf: add "nodes list" configuration option
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 6 Jun 2024 14:00:09 +0000 (10:00 -0400)
committerMartin Schwenke <martins@samba.org>
Tue, 6 Aug 2024 00:43:36 +0000 (00:43 +0000)
Add a "nodes list" configuration option to the [cluster] section of the
ctdb server config. This option will be used similarly to the `cluster
lock` parameter works. When unset it defaults to the same value as
before (/etc/ctdb/nodes). If given a path that is not prefixed by `!` it
instead loads the nodes file from the given path If given a path
prefixed by `!` then it executes the path as a command and reads the
standard output as if it were the content of the nodes file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/conf/cluster_conf.c
ctdb/conf/cluster_conf.h
ctdb/conf/ctdb_config.c
ctdb/conf/ctdb_config.h
ctdb/tests/UNIT/cunit/config_test_001.sh

index b49a24400265a6eac0737b9df1b4e67068878ba7..fd1c9230906621ed28db128d224f67a596c65861 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "lib/util/debug.h"
 
+#include "common/path.h"
+
 #include "conf/conf.h"
 
 #include "conf/cluster_conf.h"
@@ -169,6 +171,11 @@ void cluster_conf_init(struct conf_context *conf)
                           CLUSTER_CONF_RECOVERY_LOCK,
                           NULL,
                           validate_recovery_lock);
+       conf_define_string(conf,
+                          CLUSTER_CONF_SECTION,
+                          CLUSTER_CONF_NODES_LIST,
+                          NULL,
+                          check_static_string_change);
        conf_define_integer(conf,
                            CLUSTER_CONF_SECTION,
                            CLUSTER_CONF_LEADER_TIMEOUT,
@@ -180,3 +187,17 @@ void cluster_conf_init(struct conf_context *conf)
                            true,
                            NULL);
 }
+
+char *cluster_conf_nodes_list(TALLOC_CTX *mem_ctx, struct conf_context *conf)
+{
+       const char *out = NULL;
+       int ret = conf_get_string(conf,
+                                 CLUSTER_CONF_SECTION,
+                                 CLUSTER_CONF_NODES_LIST,
+                                 &out,
+                                 NULL);
+       if (ret == 0 && out != NULL) {
+               return talloc_strdup(mem_ctx, out);
+       }
+       return path_etcdir_append(mem_ctx, "nodes");
+}
index 9775b6fc080f420c4dc79842e0c2fbff709a63e0..584732b39ffa7ba6f7c10803fc7a7229813aaa1d 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef __CTDB_CLUSTER_CONF_H__
 #define __CTDB_CLUSTER_CONF_H__
 
+#include <talloc.h>
+
 #include "conf/conf.h"
 
 #define CLUSTER_CONF_SECTION "cluster"
 #define CLUSTER_CONF_NODE_ADDRESS    "node address"
 #define CLUSTER_CONF_CLUSTER_LOCK    "cluster lock"
 #define CLUSTER_CONF_RECOVERY_LOCK   "recovery lock"
+#define CLUSTER_CONF_NODES_LIST      "nodes list"
 #define CLUSTER_CONF_LEADER_TIMEOUT  "leader timeout"
 #define CLUSTER_CONF_LEADER_CAPABILITY "leader capability"
 
 void cluster_conf_init(struct conf_context *conf);
 
+/**
+ * @brief Return the value of the nodes list configuration parameter.
+ *
+ * This function is used to fetch the value set in the ctdb.conf (or equivalent)
+ * for 'nodes list' a value that is then used to fetch the actual nodes list
+ * of private node addresses. If a value is not present in the configuration
+ * file a backwards compatible default value will be returned.
+ *
+ * @param[in] mem_ctx  TALLOC memory context
+ * @param[in] conf  A configuration context
+ * @return string or NULL on memory allocation error
+ */
+char *cluster_conf_nodes_list(TALLOC_CTX *mem_ctx, struct conf_context *conf);
+
 #endif /* __CTDB_CLUSTER_CONF_H__ */
index e3e8cce8d6ba5020ccaad8a9ce59cdba4a07285b..f1f9ec020f0d03ec03854cac82f2b459bd544970 100644 (file)
@@ -57,6 +57,10 @@ static void setup_config_pointers(struct conf_context *conf)
                                   CLUSTER_CONF_SECTION,
                                   CLUSTER_CONF_RECOVERY_LOCK,
                                   &ctdb_config.recovery_lock);
+       conf_assign_string_pointer(conf,
+                                  CLUSTER_CONF_SECTION,
+                                  CLUSTER_CONF_NODES_LIST,
+                                  &ctdb_config.nodes_list);
        conf_assign_integer_pointer(conf,
                                    CLUSTER_CONF_SECTION,
                                    CLUSTER_CONF_LEADER_TIMEOUT,
index 7b588c3cd59f35f58f1374c775f1d821a08231d8..2cf6a16f1cb91cdf76f98a9a6334c55d6f86cebd 100644 (file)
@@ -28,6 +28,7 @@ struct ctdb_config {
        const char *node_address;
        const char *cluster_lock;
        const char *recovery_lock;
+       const char *nodes_list;
        int leader_timeout;
        bool leader_capability;
 
index 70bf77f7939e089c664fe305cd8e2e2aa55af81c..9e7ac46261885a8fca8da2f610b3327a8ebf8913 100755 (executable)
@@ -36,6 +36,7 @@ ok <<EOF
        # node address = 
        # cluster lock = 
        # recovery lock = 
+       # nodes list = 
        # leader timeout = 5
        # leader capability = true
 [database]