ctdb: let "moveip" end with CTDB_CONTROL_IPREALLOCATED to all connected nodes
authorStefan Metzmacher <metze@samba.org>
Fri, 24 Nov 2023 09:53:44 +0000 (10:53 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 9 Jan 2024 10:08:20 +0000 (11:08 +0100)
This matches the behavior of takeover_send/recv() from
ctdb_takeover_helper.c.

It means we consistently call the ipreallocated event scripts
and also send CTDB_SRVID_IPREALLOCATED after moving ips.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 589ebabc95eef0c301a47696e82c0ac341027597)

ctdb/tools/ctdb.c

index 20738bdaa5558a5f732fd805e18fc33f030f97cf..119e2bfab0b6adf9b38c843a380d3d5d43cfe353 100644 (file)
@@ -87,6 +87,10 @@ static int disable_takeover_runs(TALLOC_CTX *mem_ctx,
                                 uint32_t timeout,
                                 uint32_t *pnn_list,
                                 int count);
+static int send_ipreallocated_control_to_nodes(TALLOC_CTX *mem_ctx,
+                                              struct ctdb_context *ctdb,
+                                              uint32_t *pnn_list,
+                                              int count);
 
 /*
  * Utility Functions
@@ -3947,7 +3951,10 @@ static int moveip(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
                return ret;
        }
 
-       return 0;
+       return send_ipreallocated_control_to_nodes(mem_ctx,
+                                                  ctdb,
+                                                  connected_pnn,
+                                                  connected_count);
 }
 
 static int control_moveip(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
@@ -5957,6 +5964,32 @@ fail:
        return ret;
 }
 
+static int send_ipreallocated_control_to_nodes(TALLOC_CTX *mem_ctx,
+                                              struct ctdb_context *ctdb,
+                                              uint32_t *pnn_list,
+                                              int count)
+{
+       struct ctdb_req_control request;
+       int ret;
+
+       ctdb_req_control_ipreallocated(&request);
+       ret = ctdb_client_control_multi(mem_ctx,
+                                       ctdb->ev,
+                                       ctdb->client,
+                                       pnn_list,
+                                       count,
+                                       TIMEOUT(),
+                                       &request,
+                                       NULL,  /* perr_list */
+                                       NULL); /* preply */
+       if (ret != 0) {
+               fprintf(stderr, "Failed to send ipreallocated\n");
+               return ret;
+       }
+
+       return 0;
+}
+
 static int control_reloadips(TALLOC_CTX *mem_ctx, struct ctdb_context *ctdb,
                             int argc, const char **argv)
 {