1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

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@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
John Mulligan 2024-06-06 10:00:09 -04:00 committed by Martin Schwenke
parent bab5170528
commit 315890e845
5 changed files with 44 additions and 0 deletions

View 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");
}

View 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"
@ -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__ */

View 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,

View 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;

View File

@ -36,6 +36,7 @@ ok <<EOF
# node address =
# cluster lock =
# recovery lock =
# nodes list =
# leader timeout = 5
# leader capability = true
[database]