ctdb: send a CTDB_SRVID_IPREALLOCATED message after CTDB_EVENT_IPREALLOCATED
authorStefan Metzmacher <metze@samba.org>
Thu, 23 Nov 2023 14:04:09 +0000 (15:04 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 4 Jan 2024 11:39:36 +0000 (11:39 +0000)
Event scripts run the "ipreallocated" hook in order to notice that some ip addresses
in the cluster potentially changed.

CTDB_SRVID_IPREALLOCATED gives C code a chance to get notified as well once the event
scripts are finished.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/protocol/protocol.h
ctdb/protocol/protocol_debug.c
ctdb/protocol/protocol_message.c
ctdb/server/ctdb_takeover.c

index 3b66c403ab84547e1e8dfb36ad35e846aac585c7..009a0df06afd2350a87066f01fdc76db70eb1000 100644 (file)
@@ -140,6 +140,9 @@ struct ctdb_call {
 /* SRVID to inform clients that an IP address has been taken over */
 #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL
 
+/* SRVID to inform clients that CTDB_EVENT_IPREALLOCATED finished */
+#define CTDB_SRVID_IPREALLOCATED 0xF302000000000000LL
+
 /* SRVID to inform recovery daemon of the node flags - OBSOLETE */
 #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL
 
index ae091b04d321e96d44401d018f83195dc4884ccd..f1e1fc070d92f4f4c428a75c84b7f27dba75a3a5 100644 (file)
@@ -301,6 +301,8 @@ static void ctdb_srvid_print(uint64_t srvid, FILE *fp)
                fprintf(fp, "RELEASE_IP");
        } else if (srvid == CTDB_SRVID_TAKE_IP) {
                fprintf(fp, "TAKE_IP");
+       } else if (srvid == CTDB_SRVID_IPREALLOCATED) {
+               fprintf(fp, "IPREALLOCATED");
        } else if (srvid == CTDB_SRVID_SET_NODE_FLAGS) {
                fprintf(fp, "SET_NODE_FLAGS");
        } else if (srvid == CTDB_SRVID_RECD_UPDATE_IP) {
index e2202bb78d509920d21550f66124ec675f8194ad..8d323227914d5526ae0558a27cd423d16b76e204 100644 (file)
@@ -57,6 +57,9 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata,
                len = ctdb_string_len(&mdata->ipaddr);
                break;
 
+       case CTDB_SRVID_IPREALLOCATED:
+               break;
+
        case CTDB_SRVID_SET_NODE_FLAGS:
                len = ctdb_node_flag_change_len(mdata->flag_change);
                break;
@@ -148,6 +151,9 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata,
                ctdb_string_push(&mdata->ipaddr, buf, &np);
                break;
 
+       case CTDB_SRVID_IPREALLOCATED:
+               break;
+
        case CTDB_SRVID_SET_NODE_FLAGS:
                ctdb_node_flag_change_push(mdata->flag_change, buf, &np);
                break;
@@ -244,6 +250,9 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen,
                                       &np);
                break;
 
+       case CTDB_SRVID_IPREALLOCATED:
+               break;
+
        case CTDB_SRVID_SET_NODE_FLAGS:
                ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx,
                                                 &mdata->flag_change, &np);
index e333105e6335272fed17a1d76fafe7ba46a0d3e8..b622fafd95faa9563b7c0dac304fd864fba2b6b2 100644 (file)
@@ -2399,6 +2399,7 @@ static void ctdb_ipreallocated_callback(struct ctdb_context *ctdb,
 {
        struct ipreallocated_callback_state *state =
                talloc_get_type(p, struct ipreallocated_callback_state);
+       TDB_DATA data = { .dsize = 0, };
 
        if (status != 0) {
                DEBUG(DEBUG_ERR,
@@ -2409,6 +2410,9 @@ static void ctdb_ipreallocated_callback(struct ctdb_context *ctdb,
                }
        }
 
+       D_INFO("Sending IPREALLOCATED message\n");
+       ctdb_daemon_send_message(ctdb, ctdb->pnn, CTDB_SRVID_IPREALLOCATED, data);
+
        ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);
        talloc_free(state);
 }