feat(controller): OPCode_probeConfigTag handler with Request envelope reply (bug-1506)
- Add OPCode_probeConfigTag dispatch in cluster.c - Implement probe_config_tag handler returning config tag via standard xce_reply() → RequestReply envelope - Populate redirectHost/redirectPort for follow_redirects support - Wire probeConfigTag reply through typemap - Add probeConfigTagReply struct to controller.capnp schema
This commit is contained in:
parent
b00e97ffe6
commit
90d7dd8241
5 changed files with 64 additions and 8 deletions
|
|
@ -816,6 +816,15 @@ static int myreq_handler(vtask_t* task)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case OPCode_probeConfigTag:
|
||||||
|
/* bug-1506: return the current config generation tag for xceadmin's
|
||||||
|
* config push --dry-run. Read-only — no WAL commit, no SHA
|
||||||
|
* verification. Any role (PRIMARY or STANDBY) can service this;
|
||||||
|
* ha_dispatch_gate already allows OPCode_probeConfigTag on every
|
||||||
|
* non-INIT role. Redirect hints are filled inside the handler. */
|
||||||
|
rc = handle_probe_config_tag(c, ep, &request);
|
||||||
|
break;
|
||||||
|
|
||||||
case OPCode_schedAdmin: {
|
case OPCode_schedAdmin: {
|
||||||
/* Stateless pass-through forward to the scheduler (task 10.1, Req
|
/* Stateless pass-through forward to the scheduler (task 10.1, Req
|
||||||
* 5.10). The controller commits no WAL entry and interprets no
|
* 5.10). The controller commits no WAL entry and interprets no
|
||||||
|
|
|
||||||
|
|
@ -1891,6 +1891,48 @@ int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* fill_redirect_reply is defined in join.c (no header declaration). */
|
||||||
|
extern void fill_redirect_reply(xce_reply_t *reply, const ha_state_t *ha);
|
||||||
|
|
||||||
|
/* ── handle_probe_config_tag ──────────────────────────────────────────────
|
||||||
|
*
|
||||||
|
* Server-side handler for OPCode_probeConfigTag (bug-1506). Returns the
|
||||||
|
* current config_version_tag so xceadmin's config push --dry-run can
|
||||||
|
* report the real generation number instead of fabricating "accepted=True"
|
||||||
|
* with no wire signal.
|
||||||
|
*
|
||||||
|
* Unlike handle_upgrade_config, no SHA verification, no decode, no WAL
|
||||||
|
* commit — just a read of an in-memory field. Usable by any role (PRIMARY
|
||||||
|
* or STANDBY); the ha_dispatch_gate already allows OPCode_probeConfigTag
|
||||||
|
* on every non-INIT role. Redirect hints are filled via fill_redirect_reply
|
||||||
|
* so xceadmin's follow_redirects path works identically to push_config.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int handle_probe_config_tag(cluster_t *c, endpoint_t *ep, xce_request_t *req)
|
||||||
|
{
|
||||||
|
xce_reply_t reply;
|
||||||
|
probe_config_tag_reply_t prep;
|
||||||
|
|
||||||
|
memset(&prep, 0, sizeof(prep));
|
||||||
|
prep.config_tag = c->myconf->config_version_tag;
|
||||||
|
|
||||||
|
init_reply_by_req(&reply, req);
|
||||||
|
reply.status = 0;
|
||||||
|
reply.data_which = RequestReply_data_probeconfigtagreplymsg;
|
||||||
|
reply.data.probeconfigtagreplymsg = &prep;
|
||||||
|
|
||||||
|
/* If this is a standby, redirect the admin tool to the primary
|
||||||
|
* (same pattern as handle_controller_join). Do NOT redirect when
|
||||||
|
* we ARE the primary — that would send the client back to us and
|
||||||
|
* infinite-loop inside follow_redirects. */
|
||||||
|
if (ha_should_redirect(&c->ha))
|
||||||
|
fill_redirect_reply(&reply, &c->ha);
|
||||||
|
|
||||||
|
xce_reply(ep, c->myhost, &reply);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ── xce_probe_config_tag ───────────────────────────────────────────────────
|
/* ── xce_probe_config_tag ───────────────────────────────────────────────────
|
||||||
*
|
*
|
||||||
* Single-RTT config tag probe to one peer controller over SSL.
|
* Single-RTT config tag probe to one peer controller over SSL.
|
||||||
|
|
|
||||||
|
|
@ -351,6 +351,7 @@ int push_config_to_standbys(cluster_t *c, const uint8_t *bytes, size_t blen,
|
||||||
* Only callable when CONF_ENABLE_UPGRADE_CONFIG is set.
|
* Only callable when CONF_ENABLE_UPGRADE_CONFIG is set.
|
||||||
*/
|
*/
|
||||||
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req);
|
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req);
|
||||||
|
int handle_probe_config_tag(cluster_t *c, endpoint_t *ep, xce_request_t *req);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ha_stream_wal_to_standby: batch-stream WAL entries [standby_lsn+1, committed_lsn]
|
* ha_stream_wal_to_standby: batch-stream WAL entries [standby_lsn+1, committed_lsn]
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,14 @@ typedef struct {
|
||||||
uint64_t peer_last_log_lsn;
|
uint64_t peer_last_log_lsn;
|
||||||
} request_vote_reply_t;
|
} request_vote_reply_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
} probe_config_tag_req_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint64_t config_tag;
|
||||||
|
} probe_config_tag_reply_t;
|
||||||
|
|
||||||
/* Heartbeat reply state report — carries standby's applied_lsn and config_tag,
|
/* Heartbeat reply state report — carries standby's applied_lsn and config_tag,
|
||||||
* plus its raft term so the primary can discover a higher term it lost track
|
* plus its raft term so the primary can discover a higher term it lost track
|
||||||
* of (bug-1421 term-discovery: an AE reject response never reaches the raft
|
* of (bug-1421 term-discovery: an AE reject response never reaches the raft
|
||||||
|
|
@ -291,6 +299,7 @@ typedef struct {
|
||||||
xce_ctrlstatus_t* ctrlstatus;
|
xce_ctrlstatus_t* ctrlstatus;
|
||||||
xce_fetchfile_reply_t* fetchfilereply;
|
xce_fetchfile_reply_t* fetchfilereply;
|
||||||
sched_admin_reply_t* schedadminreplymsg;
|
sched_admin_reply_t* schedadminreplymsg;
|
||||||
|
probe_config_tag_reply_t* probeconfigtagreplymsg;
|
||||||
} data;
|
} data;
|
||||||
/* Req 7: standby redirect fields — populated when status == XCE_ERR_STANDBY */
|
/* Req 7: standby redirect fields — populated when status == XCE_ERR_STANDBY */
|
||||||
char *redirect_host;
|
char *redirect_host;
|
||||||
|
|
@ -331,6 +340,7 @@ typedef struct {
|
||||||
snapshot_transfer_t* snapshottransfermsg;
|
snapshot_transfer_t* snapshottransfermsg;
|
||||||
xce_fetchfile_t* fetchfilemsg;
|
xce_fetchfile_t* fetchfilemsg;
|
||||||
sched_admin_req_t* schedadminmsg;
|
sched_admin_req_t* schedadminmsg;
|
||||||
|
probe_config_tag_req_t* probeconfigtagrequestmsg;
|
||||||
} body;
|
} body;
|
||||||
} xce_request_t;
|
} xce_request_t;
|
||||||
|
|
||||||
|
|
@ -341,14 +351,6 @@ typedef struct {
|
||||||
* request_vote_req_t and request_vote_reply_t are defined above
|
* request_vote_req_t and request_vote_reply_t are defined above
|
||||||
* xce_reply_t so they can be used in the xce_request_t body union. */
|
* xce_reply_t so they can be used in the xce_request_t body union. */
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char *name;
|
|
||||||
} probe_config_tag_req_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t config_tag;
|
|
||||||
} probe_config_tag_reply_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t term;
|
uint64_t term;
|
||||||
uint64_t lsn;
|
uint64_t lsn;
|
||||||
|
|
|
||||||
|
|
@ -593,6 +593,7 @@ struct RequestReply $C.mapname("xce_reply_t"){
|
||||||
ctrlstatus @17: CtrlStatus; # ctrlstatus reply: identity/health snapshot
|
ctrlstatus @17: CtrlStatus; # ctrlstatus reply: identity/health snapshot
|
||||||
fetchfilereply @18: FetchFileReply;
|
fetchfilereply @18: FetchFileReply;
|
||||||
schedadminreplymsg @19: SchedAdminReply;
|
schedadminreplymsg @19: SchedAdminReply;
|
||||||
|
probeconfigtagreplymsg @20: ProbeConfigTagReply;
|
||||||
}
|
}
|
||||||
|
|
||||||
redirectHost @11: Text $C.mapname("redirect_host");
|
redirectHost @11: Text $C.mapname("redirect_host");
|
||||||
|
|
@ -710,6 +711,7 @@ struct Request $C.mapname("xce_request_t"){
|
||||||
snapshottransfermsg @29: SnapshotTransfer;
|
snapshottransfermsg @29: SnapshotTransfer;
|
||||||
fetchfilemsg @30: FetchFileMsg;
|
fetchfilemsg @30: FetchFileMsg;
|
||||||
schedadminmsg @31: SchedAdminRequest;
|
schedadminmsg @31: SchedAdminRequest;
|
||||||
|
probeconfigtagrequestmsg @32: ProbeConfigTagRequest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue