[SCM] CTDB repository - branch master updated - ctdb-2.4-116-ga3d63a9

Amitay Isaacs amitay at samba.org
Tue Oct 22 05:14:48 MDT 2013


The branch, master has been updated
       via  a3d63a9db89d08bb284b3b3a6db773422f21b477 (commit)
       via  c11803e3dcc905a45a08d743595e63f9ca445f0d (commit)
       via  21b4d1aba00902f1eee0cbf4f082b0794fd5b738 (commit)
       via  20e705e63bd3b20837cc3ac92fdcf2a9650ccfc8 (commit)
       via  2b6dc0d2799f3563b767622b6f9246450aa4036b (commit)
       via  30ca419aa1c78008f81839497921bbfba480e7fc (commit)
       via  913f229508302378212678d98c22606a4954b09c (commit)
      from  1c0a627df1b510f49c65ffeb4474240c8856cdf2 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a3d63a9db89d08bb284b3b3a6db773422f21b477
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:52:01 2013 +1100

    ctdbd: Pass the public address file location in ctdb context
    
    No need to pass it as an extra argument to ctdb_start_daemon.
    
    Also ensure options.public_address_list gets a nice static default.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit c11803e3dcc905a45a08d743595e63f9ca445f0d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 1 15:13:29 2013 +1000

    ctdbd: Debug locks by default with override from enviroment variable
    
    Default is debug_locks.sh, relative to CTDB_BASE.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 21b4d1aba00902f1eee0cbf4f082b0794fd5b738
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 15 14:10:58 2013 +1100

    ctdbd: Default for event_script_dir should use CTDB_BASE
    
    Also get rid of ctdb_set_event_script_dir().  It creates an
    unnecessary copy of something that will be around for the lifetime of
    the process.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 20e705e63bd3b20837cc3ac92fdcf2a9650ccfc8
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:33:10 2013 +1100

    ctdbd: Add nodes_file member to struct ctdb_context
    
    This allows ctdb_load_nodes_file() to move to ctdb_server.c and
    ctdb_set_nlist() to become static.
    
    Setting ctdb->nodes_file needs to be done early, before the nodes file
    is loaded.  It is now set from CTDB_BASE instead ETCDIR, so setting
    CTDB_BASE also needs to be done earlier.
    
    Unhack ctdbd_test.c - it no longer needs to define
    ctdb_load_nodes_file().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 2b6dc0d2799f3563b767622b6f9246450aa4036b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:43:47 2013 +1100

    tools/ctdb: CTDB_BASE is the default location of configuration files
    
    Ensure that environment variable CTDB_BASE is set.
    
    Update defaults for nodes and natgw_nodes to use CTDB_BASE.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 30ca419aa1c78008f81839497921bbfba480e7fc
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 15 14:02:31 2013 +1100

    ctdbd: Don't check CTDB_BASE before setting it, just don't override
    
    That's what the 3rd argument to setenv(3) is for...  :-)
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 913f229508302378212678d98c22606a4954b09c
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 22 15:36:30 2013 +1100

    tests/integration: Pass --valgrinding option when running under valgrind
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 include/ctdb_client.h          |    6 ----
 include/ctdb_private.h         |    5 +--
 server/ctdb_daemon.c           |    5 +--
 server/ctdb_lock.c             |   20 ++++++++++++---
 server/ctdb_server.c           |   12 ++++++++-
 server/ctdb_takeover.c         |   10 --------
 server/ctdbd.c                 |   51 +++++++++++++++++++++------------------
 tests/scripts/integration.bash |    4 +++
 tests/src/ctdbd_test.c         |    2 -
 tools/ctdb.c                   |   17 +++++++++++-
 10 files changed, 77 insertions(+), 55 deletions(-)


Changeset truncated at 500 lines:

diff --git a/include/ctdb_client.h b/include/ctdb_client.h
index ca2f762..c8c37da 100644
--- a/include/ctdb_client.h
+++ b/include/ctdb_client.h
@@ -85,12 +85,6 @@ int ctdb_set_socketname(struct ctdb_context *ctdb, const char *socketname);
 const char *ctdb_get_socketname(struct ctdb_context *ctdb);
 
 /*
-  tell ctdb what nodes are available. This takes a filename, which will contain
-  1 node address per line, in a transport specific format
-*/
-int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist);
-
-/*
   Check that a specific ip address exists in the node list and returns
   the id for the node or -1
 */
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 13e482f..f261867 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -549,6 +549,7 @@ struct ctdb_context {
 
 	struct ctdb_reloadips_handle *reload_ips;
 
+	const char *nodes_file;
 	const char *public_addresses_file;
 	struct trbt_tree *child_processes; 
 
@@ -768,8 +769,7 @@ struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
 
 
 int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork,
-		      bool use_syslog,
-		      const char *public_address_list);
+		      bool use_syslog);
 struct ctdb_call_state *ctdbd_call_send(struct ctdb_db_context *ctdb_db, struct ctdb_call *call);
 int ctdbd_call_recv(struct ctdb_call_state *state, struct ctdb_call *call);
 
@@ -1218,7 +1218,6 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
 			      const char *iface,
 			      const char *ip);
 int ctdb_set_event_script(struct ctdb_context *ctdb, const char *script);
-int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir);
 int ctdb_set_notification_script(struct ctdb_context *ctdb, const char *script);
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
 		      uint32_t *force_rebalance_nodes,
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 92dc8de..cbe6b23 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -1145,7 +1145,7 @@ static void ctdb_create_pidfile(pid_t pid)
 /*
   start the protocol going as a daemon
 */
-int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog, const char *public_address_list)
+int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 {
 	int res, ret = -1;
 	struct fd_event *fde;
@@ -1261,8 +1261,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog,
 
 	initialise_node_flags(ctdb);
 
-	if (public_address_list) {
-		ctdb->public_addresses_file = public_address_list;
+	if (ctdb->public_addresses_file) {
 		ret = ctdb_set_public_addresses(ctdb, true);
 		if (ret == -1) {
 			DEBUG(DEBUG_ALERT,("Unable to setup public address list\n"));
diff --git a/server/ctdb_lock.c b/server/ctdb_lock.c
index 1d27a44..fc437b0 100644
--- a/server/ctdb_lock.c
+++ b/server/ctdb_lock.c
@@ -495,7 +495,7 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 				    struct timeval current_time,
 				    void *private_data)
 {
-	const char *cmd = getenv("CTDB_DEBUG_LOCKS");
+	static const char * debug_locks = NULL;
 	struct lock_context *lock_ctx;
 	struct ctdb_context *ctdb;
 	pid_t pid;
@@ -515,12 +515,24 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 		       timeval_elapsed(&lock_ctx->start_time)));
 	}
 
-	/* fire a child process to find the blocking process */
-	if (cmd != NULL) {
+	/* Fire a child process to find the blocking process. */
+	if (debug_locks == NULL) {
+		debug_locks = getenv("CTDB_DEBUG_LOCKS");
+		if (debug_locks == NULL) {
+			debug_locks = talloc_asprintf(ctdb,
+						      "%s/debug_locks.sh",
+						      getenv("CTDB_BASE"));
+		}
+	}
+	if (debug_locks != NULL) {
 		pid = fork();
 		if (pid == 0) {
-			execl(cmd, cmd, NULL);
+			execl(debug_locks, debug_locks, NULL);
 		}
+	} else {
+		DEBUG(DEBUG_WARNING,
+		      (__location__
+		       " Unable to setup lock debugging - no memory?\n"));
 	}
 
 	/* reset the timeout timer */
diff --git a/server/ctdb_server.c b/server/ctdb_server.c
index d0c3461..1c0fa4c 100644
--- a/server/ctdb_server.c
+++ b/server/ctdb_server.c
@@ -197,7 +197,7 @@ static int ctdb_add_deleted_node(struct ctdb_context *ctdb)
 /*
   setup the node list from a file
 */
-int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
+static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
 {
 	char **lines;
 	int nlines;
@@ -265,6 +265,16 @@ int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
 	return 0;
 }
 
+void ctdb_load_nodes_file(struct ctdb_context *ctdb)
+{
+	int ret;
+
+	ret = ctdb_set_nlist(ctdb, ctdb->nodes_file);
+	if (ret == -1) {
+		DEBUG(DEBUG_ALERT,("ctdb_set_nlist failed - %s\n", ctdb_errstr(ctdb)));
+		exit(1);
+	}
+}
 
 /*
   setup the local node address
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index ecb0dbe..91f3030 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -1135,16 +1135,6 @@ static int ctdb_add_public_address(struct ctdb_context *ctdb,
 	return 0;
 }
 
-/*
-  setup the event script directory
-*/
-int ctdb_set_event_script_dir(struct ctdb_context *ctdb, const char *script_dir)
-{
-	ctdb->event_script_dir = talloc_strdup(ctdb, script_dir);
-	CTDB_NO_MEMORY(ctdb, ctdb->event_script_dir);
-	return 0;
-}
-
 static void ctdb_check_interfaces_event(struct event_context *ev, struct timed_event *te, 
 				  struct timeval t, void *private_data)
 {
diff --git a/server/ctdbd.c b/server/ctdbd.c
index 2857104..f3cb9d3 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -52,9 +52,10 @@ static struct {
 	int         no_publicipcheck;
 	int         max_persistent_check_errors;
 } options = {
-	.nlist = ETCDIR "/ctdb/nodes",
+	.nlist = NULL,
+	.public_address_list = NULL,
 	.transport = "tcp",
-	.event_script_dir = ETCDIR "/ctdb/events.d",
+	.event_script_dir = NULL,
 	.logfile = LOGDIR "/log.ctdb",
 	.db_dir = VARDIR "/ctdb",
 	.db_dir_persistent = VARDIR "/ctdb/persistent",
@@ -86,17 +87,6 @@ static void ctdb_recv_pkt(struct ctdb_context *ctdb, uint8_t *data, uint32_t len
 	ctdb_input_pkt(ctdb, hdr);
 }
 
-void ctdb_load_nodes_file(struct ctdb_context *ctdb)
-{
-	int ret;
-
-	ret = ctdb_set_nlist(ctdb, options.nlist);
-	if (ret == -1) {
-		DEBUG(DEBUG_ALERT,("ctdb_set_nlist failed - %s\n", ctdb_errstr(ctdb)));
-		exit(1);
-	}
-}
-
 static const struct ctdb_upcalls ctdb_upcalls = {
 	.recv_pkt       = ctdb_recv_pkt,
 	.node_dead      = ctdb_node_dead,
@@ -250,7 +240,20 @@ int main(int argc, const char *argv[])
 	 */
 	ctdb->pnn = -1;
 
+	/* Default value for CTDB_BASE - don't override */
+	setenv("CTDB_BASE", ETCDIR "/ctdb", 0);
+
 	/* tell ctdb what nodes are available */
+	if (options.nlist != NULL) {
+		ctdb->nodes_file = options.nlist;
+	} else {
+		ctdb->nodes_file =
+			talloc_asprintf(ctdb, "%s/nodes", getenv("CTDB_BASE"));
+		if (ctdb->nodes_file == NULL) {
+			DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+			exit(1);
+		}
+	}
 	ctdb_load_nodes_file(ctdb);
 
 	if (options.db_dir) {
@@ -294,10 +297,15 @@ int main(int argc, const char *argv[])
 		}
 	}
 
-	ret = ctdb_set_event_script_dir(ctdb, options.event_script_dir);
-	if (ret == -1) {
-		DEBUG(DEBUG_ALERT,("Unable to setup event script directory\n"));
-		exit(1);
+	if (options.event_script_dir != NULL) {
+		ctdb->event_script_dir = options.event_script_dir;
+	} else {
+		ctdb->event_script_dir = talloc_asprintf(ctdb, "%s/events.d",
+							 getenv("CTDB_BASE"));
+		if (ctdb->event_script_dir == NULL) {
+			DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+			exit(1);
+		}
 	}
 
 	if (options.notification_script != NULL) {
@@ -315,6 +323,7 @@ int main(int argc, const char *argv[])
 		ctdb->do_setsched = 1;
 	}
 
+	ctdb->public_addresses_file = options.public_address_list;
 	ctdb->do_checkpublicip = !options.no_publicipcheck;
 
 	if (options.max_persistent_check_errors < 0) {
@@ -323,12 +332,6 @@ int main(int argc, const char *argv[])
 		ctdb->max_persistent_check_errors = (uint64_t)options.max_persistent_check_errors;
 	}
 
-	if (getenv("CTDB_BASE") == NULL) {
-		/* setup a environment variable for the event scripts to use
-		   to find the installation directory */
-		setenv("CTDB_BASE", ETCDIR "/ctdb", 1);
-	}
-
 	/* start the protocol running (as a child) */
-	return ctdb_start_daemon(ctdb, interactive?false:true, options.use_syslog, options.public_address_list);
+	return ctdb_start_daemon(ctdb, interactive?false:true, options.use_syslog);
 }
diff --git a/tests/scripts/integration.bash b/tests/scripts/integration.bash
index 59f37c9..e5f1972 100644
--- a/tests/scripts/integration.bash
+++ b/tests/scripts/integration.bash
@@ -594,6 +594,10 @@ daemons_start_1 ()
 	ctdb_options="$ctdb_options --public-addresses=$public_addresses_mine"
     fi
 
+    if [ -n "$VALGRIND" ] ; then
+	ctdb_options="$ctdb_options --valgrinding"
+    fi
+
     # We'll use "pkill -f" to kill the daemons with
     # "--socket=.* --nlist .* --nopublicipcheck" as context.
     $VALGRIND ctdbd --socket="${TEST_VAR_DIR}/sock.$pnn" $ctdb_options "$@" ||return 1
diff --git a/tests/src/ctdbd_test.c b/tests/src/ctdbd_test.c
index bf95e0b..fb29ba8 100644
--- a/tests/src/ctdbd_test.c
+++ b/tests/src/ctdbd_test.c
@@ -30,8 +30,6 @@
  */
 int script_log_level;
 bool fast_start;
-void ctdb_load_nodes_file(struct ctdb_context *ctdb) {}
-
 
 /* UTIL_OBJ */
 #include "lib/util/idtree.c"
diff --git a/tools/ctdb.c b/tools/ctdb.c
index bad09c9..49fb278 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -810,7 +810,12 @@ static struct pnn_node *read_nodes_file(TALLOC_CTX *mem_ctx)
 	/* read the nodes file */
 	nodes_list = getenv("CTDB_NODES");
 	if (nodes_list == NULL) {
-		nodes_list = "/etc/ctdb/nodes";
+		nodes_list = talloc_asprintf(mem_ctx, "%s/nodes",
+					     getenv("CTDB_BASE"));
+		if (nodes_list == NULL) {
+			DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+			exit(1);
+		}
 	}
 	lines = file_lines_load(nodes_list, &nlines, mem_ctx);
 	if (lines == NULL) {
@@ -1162,7 +1167,12 @@ static int control_natgwlist(struct ctdb_context *ctdb, int argc, const char **a
 	/* read the natgw nodes file into a linked list */
 	natgw_list = getenv("CTDB_NATGW_NODES");
 	if (natgw_list == NULL) {
-		natgw_list = "/etc/ctdb/natgw_nodes";
+		natgw_list = talloc_asprintf(tmp_ctx, "%s/natgw_nodes",
+					     getenv("CTDB_BASE"));
+		if (natgw_list == NULL) {
+			DEBUG(DEBUG_ALERT,(__location__ " Out of memory\n"));
+			exit(1);
+		}
 	}
 	lines = file_lines_load(natgw_list, &nlines, ctdb);
 	if (lines == NULL) {
@@ -6201,6 +6211,9 @@ int main(int argc, const char *argv[])
 
 	control = extra_argv[0];
 
+	/* Default value for CTDB_BASE - don't override */
+	setenv("CTDB_BASE", ETCDIR "/ctdb", 0);
+
 	ev = event_context_init(NULL);
 	if (!ev) {
 		DEBUG(DEBUG_ERR, ("Failed to initialize event system\n"));


-- 
CTDB repository


More information about the samba-cvs mailing list