We default to non-deterministic ip now where ips are "sticky" and dont change 1.2-nodeflags
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 2 Feb 2011 04:00:53 +0000 (15:00 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 8 Feb 2011 06:05:29 +0000 (17:05 +1100)
too much.
This means we can simplify the way we add ips significantly and stop
trying to move them.

We also check if the node already hosts the ip, in which case we used to return an error. Instead just print an error string but return 0, ok.
This makes it easier to script, and works around broken scripts.

CQ1021034

tools/ctdb.c

index 8a423dd1ca0bc95d6b63dfbc4ef26fdaef74b6ca..cfd7ff2a3f2c32b611cdcf96dfc30eddecffa836 100644 (file)
@@ -1626,7 +1626,6 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
 {
        int i, ret;
        int len, retries = 0;
-       uint32_t pnn;
        unsigned mask;
        ctdb_sock_addr addr;
        struct ctdb_control_ip_iface *pub;
@@ -1645,23 +1644,28 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
                return -1;
        }
 
-       ret = control_get_all_public_ips(ctdb, tmp_ctx, &ips);
+       /* read the public ip list from the node */
+       ret = ctdb_ctrl_get_public_ips(ctdb, TIMELIMIT(), options.pnn, tmp_ctx, &ips);
        if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to get public ip list from cluster\n"));
+               DEBUG(DEBUG_ERR, ("Unable to get public ip list from node %u\n", options.pnn));
                talloc_free(tmp_ctx);
-               return ret;
+               return -1;
        }
-
-
-       /* check if some other node is already serving this ip, if not,
-        * we will claim it
-        */
        for (i=0;i<ips->num;i++) {
                if (ctdb_same_ip(&addr, &ips->ips[i].addr)) {
-                       break;
+                       DEBUG(DEBUG_ERR,("Can not add ip to node. Node already hosts this ip\n"));
+                       return 0;
                }
        }
 
+
+
+       /* Dont timeout. This command waits for an ip reallocation
+          which sometimes can take wuite a while if there has
+          been a recent recovery
+       */
+       alarm(0);
+
        len = offsetof(struct ctdb_control_ip_iface, iface) + strlen(argv[1]) + 1;
        pub = talloc_size(tmp_ctx, len); 
        CTDB_NO_MEMORY(ctdb, pub);
@@ -1685,27 +1689,6 @@ static int control_addip(struct ctdb_context *ctdb, int argc, const char **argv)
                return ret;
        }
 
-       if (i == ips->num) {
-               /* no one has this ip so we claim it */
-               pnn  = options.pnn;
-       } else {
-               pnn  = ips->ips[i].pnn;
-       }
-
-       do {
-               ret = move_ip(ctdb, &addr, pnn);
-               if (ret != 0) {
-                       DEBUG(DEBUG_ERR,("Failed to move ip to node %d. wait 3 seconds and try again.\n", pnn));
-                       sleep(3);
-                       retries++;
-               }
-       } while (retries < 5 && ret != 0);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,("Failed to move ip to node %d. Giving up.\n", pnn));
-               talloc_free(tmp_ctx);
-               return ret;
-       }
-
        do {
                ret = control_ipreallocate(ctdb, argc, argv);
                if (ret != 0) {