[SCM] CTDB repository - branch 1.2-nodeflags updated - ctdb-1.9.1-258-ga9600d9

Ronnie Sahlberg sahlberg at samba.org
Sun Dec 12 20:33:29 MST 2010


The branch, 1.2-nodeflags has been updated
       via  a9600d987a38d436db0ab12c6cc3cb17d91fb81a (commit)
       via  c86707a0b9cdcdcd5a5b590644c8bdd6a5fd17c2 (commit)
       via  9e2d96fe36b167f8f6468b427539aa467fc59878 (commit)
       via  64bd651e65f790fcd14717d8c02c62db9aa6cf0a (commit)
       via  d8552be31b5b32b063d5511d67cd82fbe2896c1f (commit)
      from  693e7f954f9fdae493fb43f41eafefaad3876196 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=1.2-nodeflags


- Log -----------------------------------------------------------------
commit a9600d987a38d436db0ab12c6cc3cb17d91fb81a
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Dec 13 12:06:01 2010 +1100

    ctdb addip:
    
    After finishing "ctdb addip"  wait for an implicit "iptakeover" to complete
    the assignment to a node.
    
    This makes it more wasteful and timeconsuming when adding multiple ips
    at once, or the same ip to multiple nodes,
    but makes it easier to script the use of this command.

commit c86707a0b9cdcdcd5a5b590644c8bdd6a5fd17c2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Sun Dec 12 19:38:39 2010 +1100

    LVS
    
    update lvs configuration on ipreallocated events too

commit 9e2d96fe36b167f8f6468b427539aa467fc59878
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Sun Dec 12 14:22:20 2010 +1100

    When assigning the single-public-ip during startup,
    flag the interface as initially being "link ok"
    so that we can add it and startup.
    
    The eventscript can later drop the flag if required

commit 64bd651e65f790fcd14717d8c02c62db9aa6cf0a
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Dec 13 14:22:07 2010 +1100

    Revert "server: when we migrate off a record with data, set the MIGRATED_WITH_DATA flag"
    
    This reverts commit bb8d975376d959689e702c8e349e787fbde0db01.

commit d8552be31b5b32b063d5511d67cd82fbe2896c1f
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Dec 13 14:21:50 2010 +1100

    Revert "Add a new header flag for "migrated with data" and set this to 1"
    
    This reverts commit 4a8590f76c5e7ea68acb4d5e52ec0e8a41b65fda.

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

Summary of changes:
 config/events.d/91.lvs |    2 +-
 server/ctdb_call.c     |   28 +-----
 server/ctdb_takeover.c |    9 ++
 tools/ctdb.c           |  281 ++++++++++++++++++++++++-----------------------
 4 files changed, 156 insertions(+), 164 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/events.d/91.lvs b/config/events.d/91.lvs
index 3fbc57d..ff95811 100755
--- a/config/events.d/91.lvs
+++ b/config/events.d/91.lvs
@@ -37,7 +37,7 @@ case "$1" in
 	echo 1 > /proc/sys/net/ipv4/route/flush
 	;;
 
-     recovered|stopped)
+     recovered|stopped|ipreallocated)
 	# kill off any tcp connections
 	ipvsadm -D -t $CTDB_LVS_PUBLIC_IP:0
 	ipvsadm -D -u $CTDB_LVS_PUBLIC_IP:0
diff --git a/server/ctdb_call.c b/server/ctdb_call.c
index 7bc4c35..c5f7e7d 100644
--- a/server/ctdb_call.c
+++ b/server/ctdb_call.c
@@ -201,11 +201,6 @@ static void ctdb_call_send_dmaster(struct ctdb_db_context *ctdb_db,
 		return;
 	}
 
-	if (data->dsize != 0) {
-		header->flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
-	}
-
-
 	if (lmaster == ctdb->pnn) {
 		ctdb_send_dmaster_reply(ctdb_db, header, *key, *data, 
 					c->hdr.srcnode, c->hdr.reqid);
@@ -227,19 +222,10 @@ static void ctdb_call_send_dmaster(struct ctdb_db_context *ctdb_db,
 	memcpy(&r->data[key->dsize], data->dptr, data->dsize);
 
 	header->dmaster = c->hdr.srcnode;
-
-	if (data->dsize == 0
-	&& lmaster != ctdb->pnn
-	&& (header->flags & CTDB_REC_FLAG_MIGRATED_WITH_DATA) == 0) {
-		if (ctdb_ltdb_delete(ctdb_db, *key) != 0) {
-			ctdb_fatal(ctdb, "Failed to delete empty record when migrating it off the node");
-		}
-	} else {
-		if (ctdb_ltdb_store(ctdb_db, *key, header, *data) != 0) {
-			ctdb_fatal(ctdb, "Failed to store record in ctdb_call_send_dmaster");
-		}
+	if (ctdb_ltdb_store(ctdb_db, *key, header, *data) != 0) {
+		ctdb_fatal(ctdb, "Failed to store record in ctdb_call_send_dmaster");
 	}
-
+	
 	ctdb_queue_packet(ctdb, &r->hdr);
 
 	talloc_free(r);
@@ -267,10 +253,6 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
 	header.rsn = rsn + 1;
 	header.dmaster = ctdb->pnn;
 
-	if (data.dsize != 0) {
-		header.flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
-	}
-
 	if (ctdb_ltdb_store(ctdb_db, key, &header, data) != 0) {
 		ctdb_fatal(ctdb, "ctdb_reply_dmaster store failed\n");
 
@@ -369,10 +351,6 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 		return;
 	}
 
-	if (data.dsize != 0) {
-		header.flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
-	}
-
 	if (ctdb_lmaster(ctdb, &key) != ctdb->pnn) {
 		DEBUG(DEBUG_ALERT,("pnn %u dmaster request to non-lmaster lmaster=%u gen=%u curgen=%u\n",
 			 ctdb->pnn, ctdb_lmaster(ctdb, &key), 
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 682d17b..e3e6787 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -1000,6 +1000,7 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
 			      const char *ip)
 {
 	struct ctdb_vnn *svnn;
+	struct ctdb_iface *cur = NULL;
 	bool ok;
 	int ret;
 
@@ -1028,6 +1029,14 @@ int ctdb_set_single_public_ip(struct ctdb_context *ctdb,
 		return -1;
 	}
 
+	/* assume the single public ip interface is initially "good" */
+	cur = ctdb_find_iface(ctdb, iface);
+	if (cur == NULL) {
+		DEBUG(DEBUG_CRIT,("Can not find public interface %s used by --single-public-ip", iface));
+		return -1;
+	}
+	cur->link_up = true;
+
 	ret = ctdb_vnn_assign_iface(ctdb, svnn);
 	if (ret != 0) {
 		talloc_free(svnn);
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 3f4e2d5..0b9ceb1 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -1473,6 +1473,143 @@ find_other_host_for_public_ip(struct ctdb_context *ctdb, ctdb_sock_addr *addr)
 	return -1;
 }
 
+static uint32_t ipreallocate_finished;
+
+/*
+  handler for receiving the response to ipreallocate
+*/
+static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid, 
+			     TDB_DATA data, void *private_data)
+{
+	ipreallocate_finished = 1;
+}
+
+static void ctdb_every_second(struct event_context *ev, struct timed_event *te, struct timeval t, void *p)
+{
+	struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
+
+	event_add_timed(ctdb->ev, ctdb, 
+				timeval_current_ofs(1, 0),
+				ctdb_every_second, ctdb);
+}
+
+/*
+  ask the recovery daemon on the recovery master to perform a ip reallocation
+ */
+static int control_ipreallocate(struct ctdb_context *ctdb, int argc, const char **argv)
+{
+	int i, ret;
+	TDB_DATA data;
+	struct takeover_run_reply rd;
+	uint32_t recmaster;
+	struct ctdb_node_map *nodemap=NULL;
+	int retries=0;
+	struct timeval tv = timeval_current();
+
+	/* we need some events to trigger so we can timeout and restart
+	   the loop
+	*/
+	event_add_timed(ctdb->ev, ctdb, 
+				timeval_current_ofs(1, 0),
+				ctdb_every_second, ctdb);
+
+	rd.pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE);
+	if (rd.pnn == -1) {
+		DEBUG(DEBUG_ERR, ("Failed to get pnn of local node\n"));
+		return -1;
+	}
+	rd.srvid = getpid();
+
+	/* register a message port for receiveing the reply so that we
+	   can receive the reply
+	*/
+	ctdb_client_set_message_handler(ctdb, rd.srvid, ip_reallocate_handler, NULL);
+
+	data.dptr = (uint8_t *)&rd;
+	data.dsize = sizeof(rd);
+
+again:
+	/* check that there are valid nodes available */
+	if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn, ctdb, &nodemap) != 0) {
+		DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+		return -1;
+	}
+	for (i=0; i<nodemap->num;i++) {
+		if ((nodemap->nodes[i].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) == 0) {
+			break;
+		}
+	}
+	if (i==nodemap->num) {
+		DEBUG(DEBUG_ERR,("No recmaster available, no need to wait for cluster convergence\n"));
+		return 0;
+	}
+
+
+	ret = ctdb_ctrl_getrecmaster(ctdb, ctdb, TIMELIMIT(), options.pnn, &recmaster);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, ("Unable to get recmaster from node %u\n", options.pnn));
+		return ret;
+	}
+
+	/* verify the node exists */
+	if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), recmaster, ctdb, &nodemap) != 0) {
+		DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
+		return -1;
+	}
+
+
+	/* check tha there are nodes available that can act as a recmaster */
+	for (i=0; i<nodemap->num; i++) {
+		if (nodemap->nodes[i].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
+			continue;
+		}
+		break;
+	}
+	if (i == nodemap->num) {
+		DEBUG(DEBUG_ERR,("No possible nodes to host addresses.\n"));
+		return 0;
+	}
+
+	/* verify the recovery master is not STOPPED, nor BANNED */
+	if (nodemap->nodes[recmaster].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
+		DEBUG(DEBUG_ERR,("No suitable recmaster found. Try again\n"));
+		retries++;
+		sleep(1);
+		goto again;
+	} 
+	
+	/* verify the recovery master is not STOPPED, nor BANNED */
+	if (nodemap->nodes[recmaster].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
+		DEBUG(DEBUG_ERR,("No suitable recmaster found. Try again\n"));
+		retries++;
+		sleep(1);
+		goto again;
+	} 
+
+	ipreallocate_finished = 0;
+	ret = ctdb_client_send_message(ctdb, recmaster, CTDB_SRVID_TAKEOVER_RUN, data);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,("Failed to send ip takeover run request message to %u\n", options.pnn));
+		return -1;
+	}
+
+	tv = timeval_current();
+	/* this loop will terminate when we have received the reply */
+	while (timeval_elapsed(&tv) < 5.0 && ipreallocate_finished == 0) {
+		event_loop_once(ctdb->ev);
+	}
+	if (ipreallocate_finished == 1) {
+		return 0;
+	}
+
+	retries++;
+	sleep(1);
+	goto again;
+
+	return 0;
+}
+
+
 /*
   add a public ip address to a node
  */
@@ -1544,6 +1681,12 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
 		return -1;
 	}
 
+	ret = control_ipreallocate(ctdb, argc, argv);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, ("IP Reallocate failed on node %u\n", options.pnn));
+		return ret;
+	}
+
 	talloc_free(tmp_ctx);
 	return 0;
 }
@@ -2163,144 +2306,6 @@ static int control_getpid(struct ctdb_context *ctdb, int argc, const char **argv
 	return 0;
 }
 
-static uint32_t ipreallocate_finished;
-
-/*
-  handler for receiving the response to ipreallocate
-*/
-static void ip_reallocate_handler(struct ctdb_context *ctdb, uint64_t srvid, 
-			     TDB_DATA data, void *private_data)
-{
-	ipreallocate_finished = 1;
-}
-
-static void ctdb_every_second(struct event_context *ev, struct timed_event *te, struct timeval t, void *p)
-{
-	struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
-
-	event_add_timed(ctdb->ev, ctdb, 
-				timeval_current_ofs(1, 0),
-				ctdb_every_second, ctdb);
-}
-
-/*
-  ask the recovery daemon on the recovery master to perform a ip reallocation
- */
-static int control_ipreallocate(struct ctdb_context *ctdb, int argc, const char **argv)
-{
-	int i, ret;
-	TDB_DATA data;
-	struct takeover_run_reply rd;
-	uint32_t recmaster;
-	struct ctdb_node_map *nodemap=NULL;
-	int retries=0;
-	struct timeval tv = timeval_current();
-
-	/* we need some events to trigger so we can timeout and restart
-	   the loop
-	*/
-	event_add_timed(ctdb->ev, ctdb, 
-				timeval_current_ofs(1, 0),
-				ctdb_every_second, ctdb);
-
-	rd.pnn = ctdb_ctrl_getpnn(ctdb, TIMELIMIT(), CTDB_CURRENT_NODE);
-	if (rd.pnn == -1) {
-		DEBUG(DEBUG_ERR, ("Failed to get pnn of local node\n"));
-		return -1;
-	}
-	rd.srvid = getpid();
-
-	/* register a message port for receiveing the reply so that we
-	   can receive the reply
-	*/
-	ctdb_client_set_message_handler(ctdb, rd.srvid, ip_reallocate_handler, NULL);
-
-	data.dptr = (uint8_t *)&rd;
-	data.dsize = sizeof(rd);
-
-again:
-	/* check that there are valid nodes available */
-	if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), options.pnn, ctdb, &nodemap) != 0) {
-		DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
-		return -1;
-	}
-	for (i=0; i<nodemap->num;i++) {
-		if ((nodemap->nodes[i].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) == 0) {
-			break;
-		}
-	}
-	if (i==nodemap->num) {
-		DEBUG(DEBUG_ERR,("No recmaster available, no need to wait for cluster convergence\n"));
-		return 0;
-	}
-
-
-	ret = ctdb_ctrl_getrecmaster(ctdb, ctdb, TIMELIMIT(), options.pnn, &recmaster);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR, ("Unable to get recmaster from node %u\n", options.pnn));
-		return ret;
-	}
-
-	/* verify the node exists */
-	if (ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(), recmaster, ctdb, &nodemap) != 0) {
-		DEBUG(DEBUG_ERR, ("Unable to get nodemap from local node\n"));
-		return -1;
-	}
-
-
-	/* check tha there are nodes available that can act as a recmaster */
-	for (i=0; i<nodemap->num; i++) {
-		if (nodemap->nodes[i].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
-			continue;
-		}
-		break;
-	}
-	if (i == nodemap->num) {
-		DEBUG(DEBUG_ERR,("No possible nodes to host addresses.\n"));
-		return 0;
-	}
-
-	/* verify the recovery master is not STOPPED, nor BANNED */
-	if (nodemap->nodes[recmaster].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
-		DEBUG(DEBUG_ERR,("No suitable recmaster found. Try again\n"));
-		retries++;
-		sleep(1);
-		goto again;
-	} 
-
-	
-	/* verify the recovery master is not STOPPED, nor BANNED */
-	if (nodemap->nodes[recmaster].flags & (NODE_FLAGS_DELETED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)) {
-		DEBUG(DEBUG_ERR,("No suitable recmaster found. Try again\n"));
-		retries++;
-		sleep(1);
-		goto again;
-	} 
-
-	ipreallocate_finished = 0;
-	ret = ctdb_client_send_message(ctdb, recmaster, CTDB_SRVID_TAKEOVER_RUN, data);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR,("Failed to send ip takeover run request message to %u\n", options.pnn));
-		return -1;
-	}
-
-	tv = timeval_current();
-	/* this loop will terminate when we have received the reply */
-	while (timeval_elapsed(&tv) < 3.0) {
-		event_loop_once(ctdb->ev);
-	}
-	if (ipreallocate_finished == 1) {
-		return 0;
-	}
-
-	retries++;
-	sleep(1);
-	goto again;
-
-	return 0;
-}
-
-
 /*
   disable a remote node
  */


-- 
CTDB repository


More information about the samba-cvs mailing list