ctdb-takeover: Assign banning credits on failure to fetch public IPs
authorMartin Schwenke <martin@meltin.net>
Mon, 6 Feb 2017 01:14:10 +0000 (12:14 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 24 Feb 2017 06:47:12 +0000 (07:47 +0100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover_helper.c
ctdb/tests/takeover_helper/140.sh
ctdb/tests/takeover_helper/240.sh

index eae4bfa79ba7b1ae14ce7a40a077b92ede9ad6a0..00b83c3687738fa9c813b40f60df811beb8300b3 100644 (file)
@@ -91,6 +91,7 @@ struct get_public_ips_state {
        uint32_t *pnns;
        int count;
        struct ctdb_public_ip_list *ips;
+       uint32_t *ban_credits;
 };
 
 static void get_public_ips_done(struct tevent_req *subreq);
@@ -101,6 +102,7 @@ static struct tevent_req *get_public_ips_send(
                                struct ctdb_client_context *client,
                                uint32_t *pnns,
                                int count, int num_nodes,
+                               uint32_t *ban_credits,
                                bool available_only)
 {
        struct tevent_req *req, *subreq;
@@ -114,6 +116,7 @@ static struct tevent_req *get_public_ips_send(
 
        state->pnns = pnns;
        state->count = count;
+       state->ban_credits = ban_credits;
 
        state->ips  = talloc_zero_array(state,
                                        struct ctdb_public_ip_list,
@@ -164,6 +167,7 @@ static void get_public_ips_done(struct tevent_req *subreq)
                                D_ERR("control GET_PUBLIC_IPS failed on "
                                      "node %u, ret=%d\n", pnn, err_list[i]);
 
+                               state->ban_credits[pnn]++;
                                found_errors = true;
                        }
                }
@@ -183,6 +187,7 @@ static void get_public_ips_done(struct tevent_req *subreq)
                if (ret != 0) {
                        D_ERR("control GET_PUBLIC_IPS failed on "
                              "node %u\n", pnn);
+                       state->ban_credits[pnn]++;
                        found_errors = true;
                        continue;
                }
@@ -855,7 +860,8 @@ static void takeover_nodemap_done(struct tevent_req *subreq)
 
        subreq = get_public_ips_send(state, state->ev, state->client,
                                     state->pnns_active, state->num_active,
-                                    state->num_nodes, false);
+                                    state->num_nodes, state->ban_credits,
+                                    false);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
@@ -903,7 +909,8 @@ static void takeover_known_ips_done(struct tevent_req *subreq)
 
        subreq = get_public_ips_send(state, state->ev, state->client,
                                     pnns, count,
-                                    state->num_nodes, true);
+                                    state->num_nodes, state->ban_credits,
+                                    true);
        if (tevent_req_nomem(subreq, req)) {
                return;
        }
index 60a03f229b444a25bf4716a745d5822f5ef01d15..844a35a65e1324a3eeb0c9d0e46dab632adc5965 100755 (executable)
@@ -27,6 +27,7 @@ EOF
 required_result 255 <<EOF
 control GET_PUBLIC_IPS failed on node 2, ret=-1
 Failed to fetch known public IPs
+Assigning banning credits to node 2
 takeover run failed, ret=-1
 EOF
 test_takeover_helper
index 00004a5fffa262282d2716fb24979efe99933312..b01b458b0cd03b49d823036e7b8af0165ffad8a9 100755 (executable)
@@ -27,6 +27,7 @@ EOF
 required_result 110 <<EOF
 control GET_PUBLIC_IPS failed on node 2, ret=110
 Failed to fetch known public IPs
+Assigning banning credits to node 2
 takeover run failed, ret=110
 EOF
 test_takeover_helper