forked from lei.chen/myxce
fix(scheduler,cli): bug-1453/1454/1455/1456 remove dead CA-cert plumbing, fix scheduler HA config bugs
bug-1453: remove unused client-side CA-certificate plumbing. C-side: drop ca_cert_path from xce_cluster_config_t, do_connect()'s ca_cert param, --ca-cert flags on worker/scheduler, and controller's cert population (TLS is server-side only, SSL_VERIFY_NONE everywhere on the client side already, verified zero SSL_CTX_load_verify_locations calls in the C tree). Go-side: delete xcecli's self-signed cert TOFU-pinning flow (cmd/auth/cert/*), CACert field, SetRootCAs/ loadRootCAs, and every call site. bug-1454: fix xcecli_ctx_t leak in scheduler.c sched_init() — the unconditional initial ctx_init was never freed before the HA candidate loop re-initialized it on the first iteration. bug-1455: sched_init()'s memset(sched, 0, ...) was silently wiping sched->cluster_cfg that main.c had populated from --peers just before calling sched_init(), so --peers was always ignored and the scheduler fell back to the hardcoded localhost:9990 single-host default. Restructured sched_init() to take cluster_cfg as an explicit parameter (assigned after the memset) instead of relying on caller-side ordering with a separate sched_set_cluster_cfg() setter, which is now removed. bug-1456: revert an unsafe stack-local xce_client_config_t introduced while fixing bug-1455 — xcecli_ctx_init() stores that pointer as ctx->conf and client_failover.c dereferences it for the ctx's entire life (runtime reconnect), so a per-loop-iteration stack copy would dangle the moment sched_init() returned. Back to mutating the caller-owned, process-lifetime config in place. Verified: full ASAN build (all components), meson test suite 9/9 OK, manual scheduler testsuite 15/15, Go build/vet/test all pass.
This commit is contained in:
parent
619f41f70e
commit
94f50ce6e1
34 changed files with 1999 additions and 2274 deletions
|
|
@ -289,8 +289,7 @@ static int check_user(void)
|
|||
}
|
||||
|
||||
/* Long-option identifiers (beyond ASCII range to avoid collisions) */
|
||||
#define OPT_PEERS 256
|
||||
#define OPT_CA_CERT 257
|
||||
#define OPT_PEERS 256
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
|
@ -301,7 +300,6 @@ int main(int argc, char* argv[])
|
|||
char* custom_config_path = NULL;
|
||||
__attribute__((unused)) char worker_log[1024] = { 0 };
|
||||
const char* peers_str = NULL;
|
||||
const char* ca_cert_str = NULL;
|
||||
xce_cluster_config_t cluster_cfg = {0};
|
||||
int use_ha = 0; /* 1 when --peers given */
|
||||
|
||||
|
|
@ -394,10 +392,9 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
static struct option long_opts[] = {
|
||||
{ "peers", required_argument, NULL, OPT_PEERS },
|
||||
{ "ca-cert", required_argument, NULL, OPT_CA_CERT },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ "peers", required_argument, NULL, OPT_PEERS },
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "c:p:m:n:l:h", long_opts, NULL))
|
||||
|
|
@ -440,19 +437,16 @@ int main(int argc, char* argv[])
|
|||
case OPT_PEERS:
|
||||
peers_str = optarg;
|
||||
break;
|
||||
case OPT_CA_CERT:
|
||||
ca_cert_str = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
#ifdef VIRTUAL_CLUSTER
|
||||
printf("Usage: %s -n virtual_name [-p remote_port] [-m "
|
||||
"remote_host] [-l log_dir] [--peers list] "
|
||||
"[--ca-cert path] [-h help]\n",
|
||||
"[-h help]\n",
|
||||
argv[0]);
|
||||
#else
|
||||
printf("Usage: %s [-p remote_port] [-m remote_host] [-l log_dir] "
|
||||
"[--peers ctrl-1=host:port,...] [--ca-cert path] "
|
||||
"[--peers ctrl-1=host:port,...] "
|
||||
"[-h help]\n",
|
||||
argv[0]);
|
||||
#endif
|
||||
|
|
@ -469,16 +463,12 @@ int main(int argc, char* argv[])
|
|||
peers_str);
|
||||
return 1;
|
||||
}
|
||||
if (ca_cert_str) {
|
||||
strncpy(cluster_cfg.ca_cert_path, ca_cert_str,
|
||||
sizeof(cluster_cfg.ca_cert_path) - 1);
|
||||
}
|
||||
strncpy(cluster_cfg.identity, config.virutal_name,
|
||||
sizeof(cluster_cfg.identity) - 1);
|
||||
if (xce_cluster_config_validate(&cluster_cfg) != 0) {
|
||||
fprintf(stderr,
|
||||
"xcecd: invalid cluster config (missing ca-cert or "
|
||||
"identity?). Use --ca-cert and -n.\n");
|
||||
"xcecd: invalid cluster config (missing identity?). "
|
||||
"Use -n.\n");
|
||||
return 1;
|
||||
}
|
||||
if (cluster_cfg.candidates_count > 3) {
|
||||
|
|
@ -488,10 +478,8 @@ int main(int argc, char* argv[])
|
|||
cluster_cfg.candidates_count);
|
||||
}
|
||||
XCECD_LOG(XCE_LOG_INFO,
|
||||
"HA cluster config: %d candidate(s), identity=%s, "
|
||||
"ca_cert=%s",
|
||||
cluster_cfg.candidates_count, cluster_cfg.identity,
|
||||
cluster_cfg.ca_cert_path);
|
||||
"HA cluster config: %d candidate(s), identity=%s",
|
||||
cluster_cfg.candidates_count, cluster_cfg.identity);
|
||||
use_ha = 1;
|
||||
} else {
|
||||
XCECD_LOG(XCE_LOG_INFO,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue