ctdbd: Fix spurious warnings when running with --nopublicipcheck
authorAmitay Isaacs <amitay@gmail.com>
Wed, 4 Apr 2012 04:42:56 +0000 (14:42 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 13 Apr 2012 05:38:11 +0000 (15:38 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 67b909a0718d6cfce82ffce0830da3a6ff1f6c4b)

ctdb/server/ctdb_takeover.c

index 4aaebbfe8c6a1dbfb8ea9d2abe2ba48af040df76..43201a3832506ca37817ddac0daf7f3137b9ad76 100644 (file)
@@ -350,6 +350,8 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       if (ctdb->do_checkpublicip) {
+
        ret = ctdb_announce_vnn_iface(ctdb, state->vnn);
        if (ret != 0) {
                ctdb_request_control_reply(ctdb, state->c, NULL, -1, NULL);
@@ -357,6 +359,8 @@ static void ctdb_do_takeip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       }
+
        data.dptr  = (uint8_t *)ctdb_addr_to_str(&state->vnn->public_address);
        data.dsize = strlen((char *)data.dptr) + 1;
        DEBUG(DEBUG_INFO,(__location__ " sending TAKE_IP for '%s'\n", data.dptr));
@@ -460,6 +464,8 @@ static void ctdb_do_updateip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       if (ctdb->do_checkpublicip) {
+
        ret = ctdb_announce_vnn_iface(ctdb, state->vnn);
        if (ret != 0) {
                ctdb_request_control_reply(ctdb, state->c, NULL, -1, NULL);
@@ -467,6 +473,8 @@ static void ctdb_do_updateip_callback(struct ctdb_context *ctdb, int status,
                return;
        }
 
+       }
+
        /* the control succeeded */
        ctdb_request_control_reply(ctdb, state->c, NULL, 0, NULL);
        talloc_free(state);
@@ -591,7 +599,9 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                return 0;
        }
 
-       have_ip = ctdb_sys_have_ip(&pip->addr);
+       if (ctdb->do_checkpublicip) {
+               have_ip = ctdb_sys_have_ip(&pip->addr);
+       }
        best_iface = ctdb_vnn_best_iface(ctdb, vnn);
        if (best_iface == NULL) {
                DEBUG(DEBUG_ERR,("takeoverip of IP %s/%u failed to find"
@@ -608,6 +618,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
                have_ip = false;
        }
 
+
        if (vnn->iface == NULL && have_ip) {
                DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
                                  "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
@@ -798,19 +809,27 @@ int32_t ctdb_control_release_ip(struct ctdb_context *ctdb,
        talloc_free(vnn->takeover_ctx);
        vnn->takeover_ctx = NULL;
 
-       if (!ctdb_sys_have_ip(&pip->addr)) {
-               DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u on interface %s (ip not held)\n", 
-                       ctdb_addr_to_str(&pip->addr),
-                       vnn->public_netmask_bits, 
-                       ctdb_vnn_iface_string(vnn)));
-               ctdb_vnn_unassign_iface(ctdb, vnn);
-               return 0;
-       }
+       if (ctdb->do_checkpublicip) {
 
-       if (vnn->iface == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " release_ip of IP %s is known to the kernel, "
-                                "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
-                                ctdb_addr_to_str(&vnn->public_address)));
+               if (!ctdb_sys_have_ip(&pip->addr)) {
+                       DEBUG(DEBUG_DEBUG,("Redundant release of IP %s/%u on interface %s (ip not held)\n",
+                               ctdb_addr_to_str(&pip->addr),
+                               vnn->public_netmask_bits,
+                               ctdb_vnn_iface_string(vnn)));
+                       ctdb_vnn_unassign_iface(ctdb, vnn);
+                       return 0;
+               }
+
+               if (vnn->iface == NULL) {
+                       DEBUG(DEBUG_ERR,(__location__ " release_ip of IP %s is known to the kernel, "
+                                        "but we have no interface assigned, has someone manually configured it? Ignore for now.\n",
+                                        ctdb_addr_to_str(&vnn->public_address)));
+                       return 0;
+               }
+
+       } else if (vnn->iface == NULL) {
+               DEBUG(DEBUG_ERR, ("No interface found for IP %s.\n",
+                                    ctdb_addr_to_str(&vnn->public_address)));
                return 0;
        }
 
@@ -1059,7 +1078,9 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, const char *alist)
        }
 
 
-       ctdb_start_monitoring_interfaces(ctdb);
+       if (ctdb->do_checkpublicip) {
+               ctdb_start_monitoring_interfaces(ctdb);
+       }
 
        talloc_free(lines);
        return 0;