Skip to content

Commit

Permalink
ctdb: send a CTDB_SRVID_START_IPREALLOCATE message after CTDB_EVENT_S…
Browse files Browse the repository at this point in the history
…TART_IPREALLOCATE

Event scripts run the "start_ipreallocate" hook in order to notice
that some ip addresses in the cluster potentially changed.

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

Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: Martin Schwenke <[email protected]>
Reviewed-by: Volker Lendecke <[email protected]>
  • Loading branch information
vagnihotri-ddn authored and vlendec committed Mar 6, 2024
1 parent 2483a2a commit 7dacbcd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ctdb/protocol/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ struct ctdb_call {
/* SRVID to inform clients that CTDB_EVENT_IPREALLOCATED finished */
#define CTDB_SRVID_IPREALLOCATED 0xF302000000000000LL

/* SRVID to inform clients that CTDB_EVENT_START_IPREALLOCATE finished */
#define CTDB_SRVID_START_IPREALLOCATE 0xF303000000000000LL

/* SRVID to inform recovery daemon of the node flags - OBSOLETE */
#define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL

Expand Down
2 changes: 2 additions & 0 deletions ctdb/protocol/protocol_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ static void ctdb_srvid_print(uint64_t srvid, FILE *fp)
fprintf(fp, "TAKE_IP");
} else if (srvid == CTDB_SRVID_IPREALLOCATED) {
fprintf(fp, "IPREALLOCATED");
} else if (srvid == CTDB_SRVID_START_IPREALLOCATE) {
fprintf(fp, "START_IPREALLOCATE");
} else if (srvid == CTDB_SRVID_SET_NODE_FLAGS) {
fprintf(fp, "SET_NODE_FLAGS");
} else if (srvid == CTDB_SRVID_RECD_UPDATE_IP) {
Expand Down
9 changes: 9 additions & 0 deletions ctdb/protocol/protocol_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata,
case CTDB_SRVID_IPREALLOCATED:
break;

case CTDB_SRVID_START_IPREALLOCATE:
break;

case CTDB_SRVID_SET_NODE_FLAGS:
len = ctdb_node_flag_change_len(mdata->flag_change);
break;
Expand Down Expand Up @@ -154,6 +157,9 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata,
case CTDB_SRVID_IPREALLOCATED:
break;

case CTDB_SRVID_START_IPREALLOCATE:
break;

case CTDB_SRVID_SET_NODE_FLAGS:
ctdb_node_flag_change_push(mdata->flag_change, buf, &np);
break;
Expand Down Expand Up @@ -253,6 +259,9 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen,
case CTDB_SRVID_IPREALLOCATED:
break;

case CTDB_SRVID_START_IPREALLOCATE:
break;

case CTDB_SRVID_SET_NODE_FLAGS:
ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx,
&mdata->flag_change, &np);
Expand Down
7 changes: 7 additions & 0 deletions ctdb/server/ctdb_takeover.c
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ static void ctdb_start_ipreallocate_callback(struct ctdb_context *ctdb,
{
struct start_ipreallocate_callback_state *state = talloc_get_type_abort(
p, struct start_ipreallocate_callback_state);
TDB_DATA data = { .dsize = 0, };

if (status != 0) {
D_ERR("\"startipreallocate\" event failed (status %d)\n",
Expand All @@ -2467,6 +2468,12 @@ static void ctdb_start_ipreallocate_callback(struct ctdb_context *ctdb,
}
}

D_INFO("Sending START_IPREALLOCATE message\n");
ctdb_daemon_send_message(ctdb,
ctdb->pnn,
CTDB_SRVID_START_IPREALLOCATE,
data);

ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);
talloc_free(state);
}
Expand Down

0 comments on commit 7dacbcd

Please sign in to comment.