For deterministic IPs, check if the designated node can host the ip before
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 3 Aug 2010 04:12:17 +0000 (14:12 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 3 Aug 2010 04:12:17 +0000 (14:12 +1000)
we try to reassign it back to the home node.

If it can not, of if it is unknown, just leave the ip where it is.

This reduces the amount of "flapping" an ip address with no home node
does during recoveries.

server/ctdb_takeover.c

index cb65f29d751b7c94ab0b2b64cb0a51296ea04d27..d0de683f6b09e12634e46856b03d271c0a38f52c 100644 (file)
@@ -737,7 +737,7 @@ create_merged_ip_list(struct ctdb_context *ctdb)
  */
 int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
 {
-  int i, num_healthy, retries, num_ips;
+       int i, num_healthy, retries, num_ips;
        struct ctdb_public_ip ip;
        struct ctdb_public_ipv4 ipv4;
        uint32_t mask;
@@ -795,7 +795,12 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
        if (1 == ctdb->tunable.deterministic_public_ips) {              
                DEBUG(DEBUG_NOTICE,("Deterministic IPs enabled. Resetting all ip allocations\n"));
                for (i=0,tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next,i++) {
-                       tmp_ip->pnn = i%nodemap->num;
+                       int tmp_pnn;
+
+                       tmp_pnn = i%nodemap->num;
+                       if (can_node_serve_ip(ctdb, tmp_pnn, tmp_ip) == 0) {
+                               tmp_ip->pnn = tmp_pnn;
+                       }
                }
        }