ctdb-takeover: Generalise error handling for GET_PUBLIC_IPS
authorMartin Schwenke <martin@meltin.net>
Fri, 3 Feb 2017 05:36:04 +0000 (16:36 +1100)
committerMartin Schwenke <martins@samba.org>
Fri, 24 Feb 2017 06:47:12 +0000 (07:47 +0100)
As with other controls, processes the errors by hand instead of using
ctdb_client_control_multi_error().  This will make it easier to add
banning credits for failures.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover_helper.c

index e56c94ac9a2ac0d1700a94701200ed0b2b0c3836..14361b4ef2459b4f7e6fed2a2660c80ed2f9c1d9 100644 (file)
@@ -150,29 +150,29 @@ static void get_public_ips_done(struct tevent_req *subreq)
        struct ctdb_reply_control **reply;
        int *err_list;
        int ret, i;
-       bool status;
+       bool status, found_errors;
 
        status = ctdb_client_control_multi_recv(subreq, &ret, state, &err_list,
                                                &reply);
        TALLOC_FREE(subreq);
        if (! status) {
-               int ret2;
-               uint32_t pnn;
+               found_errors = false;
+               for (i = 0; i < state->count; i++) {
+                       if (err_list[i] != 0) {
+                               uint32_t pnn = state->pnns[i];
 
-               ret2 = ctdb_client_control_multi_error(state->pnns,
-                                                      state->count,
-                                                      err_list, &pnn);
-               if (ret2 != 0) {
-                       D_ERR("control GET_PUBLIC_IPS failed on "
-                             "node %u, ret=%d\n", pnn, ret2);
-               } else {
-                       D_ERR("control GET_PUBLIC_IPS failed, "
-                             "ret=%d\n", ret);
+                               D_ERR("control GET_PUBLIC_IPS failed on "
+                                     "node %u, ret=%d\n", pnn, err_list[i]);
+
+                               found_errors = true;
+                       }
                }
+
                tevent_req_error(req, ret);
                return;
        }
 
+       found_errors = false;
        for (i = 0; i < state->count; i++) {
                uint32_t pnn;
                struct ctdb_public_ip_list *ips;
@@ -183,14 +183,19 @@ 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);
-                       tevent_req_error(req, EIO);
-                       return;
+                       found_errors = true;
+                       continue;
                }
 
                D_INFO("Fetched public IPs from node %u\n", pnn);
                state->ips[pnn] = *ips;
        }
 
+       if (found_errors) {
+               tevent_req_error(req, EIO);
+               return;
+       }
+
        talloc_free(reply);
 
        tevent_req_done(req);