feat: wire HA candidate-list reconnect into worker+scheduler join paths

Worker (xcecd):
- Add xce_cluster_config_t cluster_cfg field to controller_connector_ctx_t
  (controller_connector.h includes xce/cluster.h)
- Populate cc_ctx->cluster_cfg from parsed cluster_cfg after xcecd_start()
  sets cc_ctx (main.c, removes the P3 placeholder)
- Replace xcecd_join_cluster() single-shot connect with a candidate-iterating
  loop: tries each candidate, calls xcecli_stop() before the next attempt,
  falls back to the original single-host path when candidates_count == 0

Scheduler (xce_scheduler):
- Add xce_cluster_config_t cluster_cfg field to xce_scheduler_t
  (scheduler.h includes xce/cluster.h)
- Add sched_set_cluster_cfg() setter
- Replace the hardcoded xcecli_start/xcecli_join pair in sched_init() with
  the same candidate-iterating pattern; original single-host path preserved
- main.c calls sched_set_cluster_cfg() before sched_init() when --peers given
  (removes the P3 placeholder comment)

checking_connection() already calls xcecd_join_cluster() on retry, giving
the worker free reconnect-after-failover behaviour for no additional code.
This commit is contained in:
Rongsong Shen 2026-05-08 03:05:56 +00:00
parent fd9cfce1c1
commit b75703ba6b
6 changed files with 131 additions and 20 deletions

View file

@ -3,6 +3,7 @@
#include "client.h"
#include "controller.capnp.h"
#include "thread_pool.h"
#include "xce/cluster.h"
#include "xcecd_utils.h"
#include "xcectx.h"
@ -13,14 +14,15 @@ typedef struct {
} api_ctx_t;
typedef struct controller_connector_ctx_s {
void* thread_pool;
void* process_manager;
char* remote_host;
char* virtual_name;
void** worker_list;
int remote_port;
int join_interval;
bool running;
void* thread_pool;
void* process_manager;
char* remote_host;
char* virtual_name;
void** worker_list;
int remote_port;
int join_interval;
bool running;
xce_cluster_config_t cluster_cfg; /* HA candidate list — empty means single-host mode */
} controller_connector_ctx_t;
extern controller_connector_ctx_t* cc_ctx;