[SCM] CTDB repository - branch master updated - ctdb-1.10-51-gd86cbf3

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


The branch, master has been updated
       via  d86cbf3d7d426c558d110d67dc985634c754a522 (commit)
       via  a4e98073d955676fdcbb91affae1de1a733d0bc2 (commit)
       via  720849b756c825fb8b285f09972a8c39f1888a99 (commit)
       via  23f81ba39ee7cd8a7360f4602b3eb264eb221552 (commit)
       via  7c37435fb517a621c45b21a21b4eb15f8bbd3c83 (commit)
      from  f44c02f45dbc13e3cc2e89ee1c96bd0d57042fcc (commit)

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


- Log -----------------------------------------------------------------
commit d86cbf3d7d426c558d110d67dc985634c754a522
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 a4e98073d955676fdcbb91affae1de1a733d0bc2
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 720849b756c825fb8b285f09972a8c39f1888a99
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 23f81ba39ee7cd8a7360f4602b3eb264eb221552
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Dec 13 14:23:48 2010 +1100

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

commit 7c37435fb517a621c45b21a21b4eb15f8bbd3c83
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Mon Dec 13 14:23:32 2010 +1100

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

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

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 19cb071..51228a2 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -1514,6 +1514,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
  */
@@ -1585,6 +1722,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;
 }
@@ -2204,144 +2347,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