server: return an error if we get an takeover ip event and we cannot serve the ip
authorStefan Metzmacher <metze@samba.org>
Mon, 18 Jan 2010 14:08:15 +0000 (15:08 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 Jan 2010 10:11:03 +0000 (11:11 +0100)
metze

server/ctdb_takeover.c

index c592f5307ba7bbf99903d708e6d093fa7bdd921e..94c4ad89bb7eacfb995212d2437fd7f51a63df22 100644 (file)
@@ -558,6 +558,7 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
        bool have_ip = false;
        bool do_updateip = false;
        bool do_takeip = false;
+       struct ctdb_iface *best_iface = NULL;
 
        /* update out vnn list */
        vnn = find_public_ip_vnn(ctdb, &pip->addr);
@@ -569,13 +570,22 @@ int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
        vnn->pnn = pip->pnn;
 
        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"
+                                "a usable interface (old %s, have_ip %d)\n",
+                                ctdb_addr_to_str(&vnn->public_address),
+                                vnn->public_netmask_bits,
+                                ctdb_vnn_iface_string(vnn),
+                                have_ip));
+               return -1;
+       }
 
        if (vnn->iface) {
                if (vnn->iface->link_up) {
-                       struct ctdb_iface *best;
-                       best = ctdb_vnn_best_iface(ctdb, vnn);
                        /* only move when the rebalance gains something */
-                       if (best && vnn->iface->references > (best->references + 1)) {
+                       if (vnn->iface->references > (best_iface->references + 1)) {
                                do_updateip = true;
                        }
                } else if (vnn->iface != best_iface) {