[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Tue Aug 6 01:51:01 UTC 2024


The branch, master has been updated
       via  a743a24d758 ctdb-doc: document nodes list configuration parameter
       via  6817eff833b ctdb-tests: add a nodestatus test that uses the nodes list command
       via  6d29c7f8194 ctdb-tests: add reloadnodes unit tests that use the nodes list command
       via  8a5b743c436 ctdb-tests: add USENODESCOMMAND directive to fake ctdb
       via  cdb5646b885 ctdb-tests: add unit test coverage for listnodes with command
       via  cfc09171355 ctdb-tools: update cli tool to optionally load nodes from command
       via  ac926a506d5 ctdb-conf: add boolean arg for verbosity when loading config
       via  a0e8304ccf2 ctdb-server: rename ctdb_load_nodes_file to ctdb_load_nodes
       via  7e7cb918066 ctdb-server: rename nodes_file field to nodes_source
       via  dc65e7082d6 ctdb-server: use the new "nodes list" configuration option
       via  315890e845b ctdb-conf: add "nodes list" configuration option
       via  bab51705280 ctdb-conf: add ctdb_read_nodes_cmd function
      from  46215ab1b34 wafsamba: Fix ABI symbol name generation

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a743a24d7588af15375f7d4cafc401523c5c0a32
Author: John Mulligan <jmulligan at redhat.com>
Date:   Fri Aug 2 13:58:59 2024 -0400

    ctdb-doc: document nodes list configuration parameter
    
    Add the initial documentation of the node list configuration parameter.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Tue Aug  6 01:50:12 UTC 2024 on atb-devel-224

commit 6817eff833b96d6a63a1468c73c81439fdb3368e
Author: John Mulligan <jmulligan at redhat.com>
Date:   Wed Jul 31 18:30:24 2024 -0400

    ctdb-tests: add a nodestatus test that uses the nodes list command
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 6d29c7f81941a20432f759592e4fae4334a65eff
Author: John Mulligan <jmulligan at redhat.com>
Date:   Wed Jul 31 16:30:13 2024 -0400

    ctdb-tests: add reloadnodes unit tests that use the nodes list command
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 8a5b743c436216f05926fabfec4a23be7f782b94
Author: John Mulligan <jmulligan at redhat.com>
Date:   Wed Jul 31 16:29:44 2024 -0400

    ctdb-tests: add USENODESCOMMAND directive to fake ctdb
    
    Add a single line USENODESCOMMAND directive to the fake ctdb in order to
    enable use of a nodes script instead of a nodes file. For simplicity
    the fake ctdb always uses `nodes.sh` in the CTDB_BASE.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit cdb5646b88589407720fef0ff7306fc6993018a3
Author: John Mulligan <jmulligan at redhat.com>
Date:   Wed Jul 31 15:36:26 2024 -0400

    ctdb-tests: add unit test coverage for listnodes with command
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit cfc0917135545d309825f18dcc04e1b172183b36
Author: John Mulligan <jmulligan at redhat.com>
Date:   Fri Jun 7 11:12:17 2024 -0400

    ctdb-tools: update cli tool to optionally load nodes from command
    
    Similar to the recent changes to the ctdb server code, add the ability
    to load the nodes from a subprocess stdout.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit ac926a506d5d3d0cfb8caeb135fe496b284ef5f6
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Aug 1 14:25:38 2024 -0400

    ctdb-conf: add boolean arg for verbosity when loading config
    
    In a future commit we will add support for loading the config file from
    the `ctdb` command line tool. Prior to this change the config file load
    func always called D_NOTICE that causes the command to emit new text and
    thus break all the tests that rely on the specific test output (not to
    mention something users could notice). This change plumbs a new
    `verbose` argument into some of the config file loading functions.
    Generally, all existing functions will have verbose set to true to match
    the existing behavior. Future callers of this function can set it to
    false in order to avoid emitting the extra text.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit a0e8304ccf2ef446dc92f701687438449c5a91d9
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Jun 6 13:53:43 2024 -0400

    ctdb-server: rename ctdb_load_nodes_file to ctdb_load_nodes
    
    Rename ctdb_load_nodes_file to ctdb_load_nodes as it can now load nodes
    from more than a regular file.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 7e7cb9180665eda8af2a485637cb1ef9be38f3dd
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Jun 6 13:50:02 2024 -0400

    ctdb-server: rename nodes_file field to nodes_source
    
    Rename the `struct ctdb_context` field nodes_file to nodes_source to
    better match that the field may indicate something other than a true
    file.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit dc65e7082d6027822f66ea067ae62b124bf0834a
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Jun 6 10:00:10 2024 -0400

    ctdb-server: use the new "nodes list" configuration option
    
    Use the new "nodes list" configuration option. Executing the given path
    if the path is prefixed by a `!`. The use case is to decouple the nodes
    file from the shared storage, especially in the case where the shared
    storage is provided by a vfs module.
    
    For an example, imagine a script that runs `curl` on a URL for a
    highly-available web server where the URL provides the content
    of the nodes file.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 315890e845bcf4c0d404622ec813ef4eb265ba56
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Jun 6 10:00:09 2024 -0400

    ctdb-conf: add "nodes list" configuration option
    
    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 at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit bab51705280a4b8ce0869d455d5345ed36981e11
Author: John Mulligan <jmulligan at redhat.com>
Date:   Thu Jun 6 10:00:10 2024 -0400

    ctdb-conf: add ctdb_read_nodes_cmd function
    
    Add ctdb_read_nodes_cmd a function that works similarly to
    ctdb_read_nodes_file but reads the nodes list from the stdout of a
    subprocess instead of a file in the file system.
    
    Signed-off-by: John Mulligan <jmulligan at redhat.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/conf/cluster_conf.c                           | 21 ++++++
 ctdb/conf/cluster_conf.h                           | 17 +++++
 ctdb/conf/conf.c                                   |  7 +-
 ctdb/conf/conf.h                                   |  3 +-
 ctdb/conf/conf_tool.c                              |  6 +-
 ctdb/conf/ctdb_config.c                            |  9 ++-
 ctdb/conf/ctdb_config.h                            |  4 +-
 ctdb/conf/node.c                                   | 77 ++++++++++++++++++----
 ctdb/doc/ctdb.7.xml                                |  4 +-
 ctdb/doc/ctdb.conf.5.xml                           | 40 +++++++++++
 ctdb/event/event_config.c                          |  2 +-
 ctdb/include/ctdb_private.h                        |  4 +-
 ctdb/server/ctdb_daemon.c                          |  2 +-
 ctdb/server/ctdb_recover.c                         |  2 +-
 ctdb/server/ctdb_recoverd.c                        |  4 +-
 ctdb/server/ctdb_server.c                          | 10 +--
 ctdb/server/ctdbd.c                                |  9 +--
 ctdb/tests/UNIT/cunit/config_test_001.sh           |  1 +
 ctdb/tests/UNIT/tool/ctdb.listnodes.001.sh         |  2 +-
 ctdb/tests/UNIT/tool/ctdb.listnodes.003.sh         | 28 ++++++++
 ctdb/tests/UNIT/tool/ctdb.listnodes.004.sh         | 29 ++++++++
 ctdb/tests/UNIT/tool/ctdb.listnodes.005.sh         | 21 ++++++
 ctdb/tests/UNIT/tool/ctdb.listnodes.006.sh         | 32 +++++++++
 ctdb/tests/UNIT/tool/ctdb.listnodes.007.sh         | 32 +++++++++
 ctdb/tests/UNIT/tool/ctdb.listnodes.008.sh         | 18 +++++
 ...db.nodestatus.001.sh => ctdb.nodestatus.008.sh} | 12 +++-
 ctdb/tests/UNIT/tool/ctdb.reloadnodes.041.sh       | 34 ++++++++++
 ctdb/tests/UNIT/tool/ctdb.reloadnodes.042.sh       | 34 ++++++++++
 ctdb/tests/src/conf_test.c                         |  6 +-
 ctdb/tests/src/fake_ctdbd.c                        | 17 ++++-
 ctdb/tools/ctdb.c                                  | 35 +++++-----
 ctdb/wscript                                       |  1 +
 32 files changed, 462 insertions(+), 61 deletions(-)
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.003.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.004.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.005.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.006.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.007.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.listnodes.008.sh
 copy ctdb/tests/UNIT/tool/{ctdb.nodestatus.001.sh => ctdb.nodestatus.008.sh} (72%)
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.reloadnodes.041.sh
 create mode 100755 ctdb/tests/UNIT/tool/ctdb.reloadnodes.042.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/conf/cluster_conf.c b/ctdb/conf/cluster_conf.c
index b49a2440026..fd1c9230906 100644
--- a/ctdb/conf/cluster_conf.c
+++ b/ctdb/conf/cluster_conf.c
@@ -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");
+}
diff --git a/ctdb/conf/cluster_conf.h b/ctdb/conf/cluster_conf.h
index 9775b6fc080..584732b39ff 100644
--- a/ctdb/conf/cluster_conf.h
+++ b/ctdb/conf/cluster_conf.h
@@ -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"
@@ -28,9 +30,24 @@
 #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__ */
diff --git a/ctdb/conf/conf.c b/ctdb/conf/conf.c
index 67046c715e2..2eb619765ad 100644
--- a/ctdb/conf/conf.c
+++ b/ctdb/conf/conf.c
@@ -1176,7 +1176,8 @@ done:
 
 int conf_load(struct conf_context *conf,
 	      const char *filename,
-	      bool ignore_unknown)
+	      bool ignore_unknown,
+	      bool verbose)
 {
 	conf->filename = talloc_strdup(conf, filename);
 	if (conf->filename == NULL) {
@@ -1185,7 +1186,9 @@ int conf_load(struct conf_context *conf,
 
 	conf->ignore_unknown = ignore_unknown;
 
-	D_NOTICE("Reading config file %s\n", filename);
+	if (verbose) {
+		D_NOTICE("Reading config file %s\n", filename);
+	}
 
 	return conf_load_internal(conf);
 }
diff --git a/ctdb/conf/conf.h b/ctdb/conf/conf.h
index 4dbf9c33723..29f36bd55e8 100644
--- a/ctdb/conf/conf.h
+++ b/ctdb/conf/conf.h
@@ -306,7 +306,8 @@ void conf_set_defaults(struct conf_context *conf);
  */
 int conf_load(struct conf_context *conf,
 	      const char *filename,
-	      bool ignore_unknown);
+	      bool ignore_unknown,
+	      bool verbose);
 
 /**
  * @brief Reload the values for configuration options
diff --git a/ctdb/conf/conf_tool.c b/ctdb/conf/conf_tool.c
index 28f6c1090d0..be4f06f57f6 100644
--- a/ctdb/conf/conf_tool.c
+++ b/ctdb/conf/conf_tool.c
@@ -57,7 +57,7 @@ static int conf_tool_dump(TALLOC_CTX *mem_ctx,
 		return EINVAL;
 	}
 
-	ret = conf_load(ctx->conf, ctx->conf_file, true);
+	ret = conf_load(ctx->conf, ctx->conf_file, true, true);
 	if (ret != 0 && ret != ENOENT) {
 		D_ERR("Failed to load config file %s\n", ctx->conf_file);
 		return ret;
@@ -97,7 +97,7 @@ static int conf_tool_get(TALLOC_CTX *mem_ctx,
 		return ENOENT;
 	}
 
-	ret = conf_load(ctx->conf, ctx->conf_file, true);
+	ret = conf_load(ctx->conf, ctx->conf_file, true, true);
 	if (ret != 0 && ret != ENOENT) {
 		D_ERR("Failed to load config file %s\n", ctx->conf_file);
 		return ret;
@@ -169,7 +169,7 @@ static int conf_tool_validate(TALLOC_CTX *mem_ctx,
 		return EINVAL;
 	}
 
-	ret = conf_load(ctx->conf, ctx->conf_file, false);
+	ret = conf_load(ctx->conf, ctx->conf_file, false, true);
 	if (ret != 0) {
 		D_ERR("Failed to load config file %s\n", ctx->conf_file);
 		return ret;
diff --git a/ctdb/conf/ctdb_config.c b/ctdb/conf/ctdb_config.c
index e3e8cce8d6b..f75bf374a80 100644
--- a/ctdb/conf/ctdb_config.c
+++ b/ctdb/conf/ctdb_config.c
@@ -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,
@@ -134,7 +138,8 @@ static void setup_config_pointers(struct conf_context *conf)
 }
 
 int ctdb_config_load(TALLOC_CTX *mem_ctx,
-		     struct conf_context **result)
+		     struct conf_context **result,
+		     bool verbose)
 {
 	struct conf_context *conf = NULL;
 	int ret = 0;
@@ -165,7 +170,7 @@ int ctdb_config_load(TALLOC_CTX *mem_ctx,
 		ret = ENOMEM;
 		goto fail;
 	}
-	ret = conf_load(conf, conf_file, true);
+	ret = conf_load(conf, conf_file, true, verbose);
 	/* Configuration file does not need to exist */
 	if (ret != 0 && ret != ENOENT) {
 		D_ERR("Failed to load configuration file %s\n", conf_file);
diff --git a/ctdb/conf/ctdb_config.h b/ctdb/conf/ctdb_config.h
index 7b588c3cd59..575e3045fa4 100644
--- a/ctdb/conf/ctdb_config.h
+++ b/ctdb/conf/ctdb_config.h
@@ -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;
 
@@ -54,6 +55,7 @@ struct ctdb_config {
 
 extern struct ctdb_config ctdb_config;
 
-int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf);
+int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf,
+		     bool verbose);
 
 #endif /* __CTDB_CONFIG_H__ */
diff --git a/ctdb/conf/node.c b/ctdb/conf/node.c
index 082b68b0d71..a242c52dfd6 100644
--- a/ctdb/conf/node.c
+++ b/ctdb/conf/node.c
@@ -29,6 +29,7 @@
 #include <talloc.h>
 
 #include "lib/util/util_file.h"
+#include "lib/util/util_strlist.h"
 
 #include "protocol/protocol.h"
 #include "protocol/protocol_util.h"
@@ -95,12 +96,10 @@ static bool node_map_add(struct ctdb_node_map *nodemap,
 	return true;
 }
 
-/* Read a nodes file into a node map */
-static struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
-						  const char *nlist)
+static struct ctdb_node_map *ctdb_parse_nodes_lines(TALLOC_CTX *mem_ctx,
+						    char **lines,
+						    int nlines)
 {
-	char **lines = NULL;
-	int nlines;
 	int i;
 	struct ctdb_node_map *nodemap = NULL;
 
@@ -109,11 +108,6 @@ static struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
-	lines = file_lines_load(nlist, &nlines, 0, mem_ctx);
-	if (lines == NULL) {
-		return NULL;
-	}
-
 	while (nlines > 0 && strcmp(lines[nlines-1], "") == 0) {
 		nlines--;
 	}
@@ -158,12 +152,67 @@ static struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
 			node = line;
 		}
 		if (!node_map_add(nodemap, node, flags)) {
-			talloc_free(lines);
 			TALLOC_FREE(nodemap);
 			return NULL;
 		}
 	}
 
+	return nodemap;
+}
+
+/* Convert a string containing a command line to an array of strings. Does not
+ * handle shell style quoting! A space will always create a new argument.
+ */
+static char **command_str_to_args(TALLOC_CTX *mem_ctx,
+				  const char *argstring)
+{
+	return str_list_make(mem_ctx, argstring, " \t");
+}
+
+/* Read a nodes file into a node map */
+static struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
+						  const char *nlist)
+{
+	char **lines = NULL;
+	int nlines;
+	struct ctdb_node_map *nodemap = NULL;
+
+	lines = file_lines_load(nlist, &nlines, 0, mem_ctx);
+	if (lines == NULL) {
+		return NULL;
+	}
+
+	nodemap = ctdb_parse_nodes_lines(mem_ctx, lines, nlines);
+	talloc_free(lines);
+	return nodemap;
+}
+
+/* Read a nodes file from an external process into a node map */
+static struct ctdb_node_map *ctdb_read_nodes_cmd(TALLOC_CTX *mem_ctx,
+						 const char *nodes_cmd)
+{
+	char **lines = NULL;
+	int nlines;
+	char *p;
+	size_t size;
+	struct ctdb_node_map *nodemap = NULL;
+	char **argl = command_str_to_args(mem_ctx, nodes_cmd);
+
+	if (argl == NULL) {
+		return NULL;
+	}
+	p = file_ploadv(argl, &size);
+	if (!p) {
+		return NULL;
+	}
+
+	lines = file_lines_parse(p, size, &nlines, mem_ctx);
+	talloc_free(p);
+	if (lines == NULL) {
+		return NULL;
+	}
+
+	nodemap = ctdb_parse_nodes_lines(mem_ctx, lines, nlines);
 	talloc_free(lines);
 	return nodemap;
 }
@@ -186,7 +235,11 @@ struct ctdb_node_map *ctdb_read_nodes(TALLOC_CTX *mem_ctx,
 {
 	struct ctdb_node_map* nodemap = NULL;
 
-	nodemap = ctdb_read_nodes_file(mem_ctx, location);
+	if (location != NULL && location[0] == '!') {
+		nodemap = ctdb_read_nodes_cmd(mem_ctx, &location[1]);
+	} else {
+		nodemap = ctdb_read_nodes_file(mem_ctx, location);
+	}
 
 	return nodemap;
 }
diff --git a/ctdb/doc/ctdb.7.xml b/ctdb/doc/ctdb.7.xml
index 0f3fbc6bf6a..be2dd5e5b65 100644
--- a/ctdb/doc/ctdb.7.xml
+++ b/ctdb/doc/ctdb.7.xml
@@ -233,8 +233,8 @@
 
       <para>
 	Some users like to put this configuration file in their
-	cluster filesystem.  A symbolic link should be used in this
-	case.
+	cluster filesystem.  A symbolic link or the
+	<parameter>nodes list</parameter> parameter can be used.
       </para>
 
       <para>
diff --git a/ctdb/doc/ctdb.conf.5.xml b/ctdb/doc/ctdb.conf.5.xml
index b9bf3a6d08b..615a61e5bfe 100644
--- a/ctdb/doc/ctdb.conf.5.xml
+++ b/ctdb/doc/ctdb.conf.5.xml
@@ -255,6 +255,46 @@
 	</listitem>
       </varlistentry>
 
+      <varlistentry>
+	<term>nodes list = <parameter>SOURCE</parameter></term>
+	<listitem>
+	  <para>
+	    SOURCE specifies the location containing the list of the private
+	    addresses of nodes in the cluster.
+	  </para>
+	  <para>
+	    Typically, SOURCE will be a path to a file that contains the list of
+	    private addresses for the cluster.
+	    For details about the content of the file please see the
+	    <citetitle>PRIVATE ADDRESSES</citetitle> section in
+	    <citerefentry><refentrytitle>ctdb</refentrytitle>
+	    <manvolnum>7</manvolnum></citerefentry>.
+	  </para>
+	  <para>
+	    As an alternative to using a file one can use an arbitrary command
+	    to provide the contents of the nodes list. If an exclamation point ('!')
+	    is the first character of the SOURCE value, the remainder of the value
+	    will be executed when the private addresses are to be read.
+	    For example, a value of <command>!/usr/local/bin/mynodes cluster1</command>
+	    would run the given command with the specified arguments. The output
+	    generated by the command (on standard out) must be the same as what is
+	    supported by a SOURCE file.
+	    The command name must be a full path to an executable. Arguments are
+	    supported, but shell-style quoting is not, and space characters will
+	    always produce a new argument for the command.
+	    It is important to note that running this command blocks until
+	    the command has completed. The run time of this command will depend
+	    on how it is implemented and environmental factors. Be aware that if
+	    the command runs for a non-trivial amount of time it can introduce
+	    undesirable stalls into ctdbd.
+	  </para>
+	  <para>
+	    Default:
+	    <filename>/usr/local/etc/ctdb/nodes</filename>
+	  </para>
+	</listitem>
+      </varlistentry>
+
       <varlistentry>
 	<term>transport = tcp|ib</term>
 	<listitem>
diff --git a/ctdb/event/event_config.c b/ctdb/event/event_config.c
index 8617ebaad30..616b5284d52 100644
--- a/ctdb/event/event_config.c
+++ b/ctdb/event/event_config.c
@@ -85,7 +85,7 @@ int event_config_init(TALLOC_CTX *mem_ctx, struct event_config **result)
 		return EINVAL;
 	}
 
-	ret = conf_load(config->conf, config->config_file, true);
+	ret = conf_load(config->conf, config->config_file, true, true);
 	if (ret != 0 && ret != ENOENT) {
 		talloc_free(config);
 		return ret;
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index cee95792ead..88f775ce126 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -328,7 +328,7 @@ struct ctdb_context {
 
 	struct ctdb_reloadips_handle *reload_ips;
 
-	const char *nodes_file;
+	const char *nodes_source;
 	const char *public_addresses_file;
 	struct trbt_tree *child_processes; 
 
@@ -840,7 +840,7 @@ struct ctdb_node *ctdb_ip_to_node(struct ctdb_context *ctdb,
 uint32_t ctdb_ip_to_pnn(struct ctdb_context *ctdb,
 			const ctdb_sock_addr *nodeip);
 
-void ctdb_load_nodes_file(struct ctdb_context *ctdb);
+void ctdb_load_nodes(struct ctdb_context *ctdb);
 
 int ctdb_set_address(struct ctdb_context *ctdb, const char *address);
 
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 97dfc80ffd1..287a76c77c3 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -2193,7 +2193,7 @@ int ctdb_control_getnodesfile(struct ctdb_context *ctdb,
 
 	CHECK_CONTROL_DATA_SIZE(0);
 
-	node_map = ctdb_read_nodes(ctdb, ctdb->nodes_file);
+	node_map = ctdb_read_nodes(ctdb, ctdb->nodes_source);
 	if (node_map == NULL) {
 		D_ERR("Failed to read nodes file\n");
 		return -1;
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index 7b30d119a3a..5a40618487e 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -158,7 +158,7 @@ ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode)
 	ctdb->num_nodes = 0;
 
 	/* load the new nodes file */
-	ctdb_load_nodes_file(ctdb);
+	ctdb_load_nodes(ctdb);
 
 	for (i=0; i<ctdb->num_nodes; i++) {
 		/* keep any identical pre-existing nodes and connections */
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 3f71c07d05d..09d5df3e9cb 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -1624,7 +1624,7 @@ static void reload_nodes_handler(uint64_t srvid, TDB_DATA data,
 
 	DEBUG(DEBUG_ERR, (__location__ " Reload nodes file from recovery daemon\n"));
 
-	ctdb_load_nodes_file(rec->ctdb);
+	ctdb_load_nodes(rec->ctdb);
 }
 
 
@@ -2677,7 +2677,7 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 
 	if (ctdb->num_nodes != nodemap->num) {
 		DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) reloading nodes file\n", ctdb->num_nodes, nodemap->num));
-		ctdb_load_nodes_file(ctdb);
+		ctdb_load_nodes(ctdb);
 		return;
 	}
 
diff --git a/ctdb/server/ctdb_server.c b/ctdb/server/ctdb_server.c
index b7a33af7ecf..0e12e8e834d 100644
--- a/ctdb/server/ctdb_server.c
+++ b/ctdb/server/ctdb_server.c
@@ -121,13 +121,13 @@ static int convert_node_map_to_list(struct ctdb_context *ctdb,
 	return 0;
 }
 
-/* Load the nodes list from a file */
-void ctdb_load_nodes_file(struct ctdb_context *ctdb)
+/* Load the nodes list from a file or sub-processes' stdout  */
+void ctdb_load_nodes(struct ctdb_context *ctdb)
 {
 	struct ctdb_node_map *node_map;
 	int ret;
 
-	node_map = ctdb_read_nodes(ctdb, ctdb->nodes_file);
+	node_map = ctdb_read_nodes(ctdb, ctdb->nodes_source);
 	if (node_map == NULL) {
 		goto fail;
 	}
@@ -143,8 +143,8 @@ void ctdb_load_nodes_file(struct ctdb_context *ctdb)
 	return;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list