feat: implement handle_config_request(), fetch_config_from_primary(), handle_controller_join()

- handle_config_request(): primary-side handler sends up-to-date flag or
  version_tag; SHA-256 integrity check guards against in-place file changes;
  sha256/bytes fields left NULL pending Task 11 typemap shims
- fetch_config_from_primary(): standby fetch with exponential backoff retry
  (20 attempts, 500ms..5s); falls back to saved config via load_primary_config();
  do_one_config_fetch() stubbed (-ENOSYS) until Task 11 wires capnp over SSL
- handle_controller_join(): registers standby endpoint in ha.standby_endpoints
  via zarray_store() for OP_upgradeConfig fan-out; sends success reply
- Moved load_primary_config() from myconf.c to config_repl.c so the unit test
  binary (which links config_repl.c but not myconf.c) can resolve it
This commit is contained in:
Rongsong Shen 2026-05-13 17:46:56 +00:00
parent 93b8616f11
commit 8f4db308da
3 changed files with 331 additions and 122 deletions

View file

@ -126,17 +126,28 @@ static int handle_controller_join(cluster_t* c, endpoint_t* ep,
xce_request_t* request)
{
xce_reply_t reply;
int rc = -ENOSYS;
ERROR("we still have not support join of controller");
init_reply_by_req(&reply, request);
reply.status = rc;
reply.status = 0;
reply.data_which = RequestReply_data_nodata;
xce_reply(ep, c->myhost, &reply);
return rc;
/* Register this endpoint for OP_upgradeConfig fan-out to standbys */
if (c->ha.standby_endpoints) {
ep_private_t *priv = (ep_private_t *)ep->data;
if (priv)
priv->role = HostRole_controller;
pthread_mutex_lock(&c->ha.lock);
zarray_store(c->ha.standby_endpoints, ep);
pthread_mutex_unlock(&c->ha.lock);
INFO("controller %s joined — %d standby(s) tracked",
request->from ? request->from->name : "?",
c->ha.standby_endpoints->count);
}
return 0;
}
static int handle_apiserver_join(cluster_t* c, endpoint_t* ep,