feat: split cluster_init() into phase1/phase2; update myapp_run() for two-phase startup with am_i_primary gating

- cluster_init_phase1(): hooks, HA init (priority from --peers), standby_endpoints zarray, cbuf
- cluster_init_phase2(): SSL ctx from ha.ssl_ctx, cluster_config guard, kvmgr sizing, iomgr, endpoint, persist, role promotion, create_lost_and_found, persist_recover
- cluster_init(): legacy wrapper calling both phases with inline SSL init for backward compat
- myapp_run(): phase1 → SSL init → am_i_primary → load_primary_config/fetch_config_from_primary → phase2 → start → run
- myreq_handler(): add OPCode_replConfig and OPCode_upgradeConfig dispatch
- handle_endpoint_error(): prune standby_endpoints on HostRole_controller disconnect
- cluster_run(): log restart_requested on exit
- config_repl.c: add create_lost_and_found, handle_config_request, handle_upgrade_config stubs
- config_repl.h: add declarations for new stubs; include netio.h + request.h
- cluster.h: declare cluster_init_phase1 and cluster_init_phase2
- myconf.c: fix FATAL → ERROR (FATAL macro undefined); add fetch_config_from_primary stub
This commit is contained in:
Rongsong Shen 2026-05-13 17:06:45 +00:00
parent ec3cab40c3
commit 6b06aa02d9
6 changed files with 307 additions and 92 deletions

View file

@ -388,6 +388,32 @@ int load_primary_config_for_test(cluster_t *c)
}
#endif
/* ── create_lost_and_found ──────────────────────── */
void create_lost_and_found(cluster_t *c) { (void)c; /* Task 10 */ }
/* ── handle_config_request ──────────────────────── */
int handle_config_request(cluster_t *c, endpoint_t *ep, xce_request_t *req)
{
(void)c;
(void)ep;
(void)req;
/* Task 9: full implementation — read versioned blob, send reply */
return -ENOSYS;
}
/* ── handle_upgrade_config ──────────────────────── */
int handle_upgrade_config(cluster_t *c, endpoint_t *ep, xce_request_t *req)
{
(void)c;
(void)ep;
(void)req;
/* Task 9: full implementation — validate, store, fan-out, restart */
return -ENOSYS;
}
/* ── sanitise_cn ────────────────────────────────── */
char *sanitise_cn(const char *src, size_t maxlen)