forked from lei.chen/myxce
feat: filter lost_and_found sentinel from pushes; reset unavail host attrs
- create_lost_and_found(): provide hostattrs_t so makeWorker succeeds - collect_queues/collect_workers (dataex.c): skip lost_and_found sentinel so it is never pushed to apiserver or scheduler - mark_worker_unavail(): reset hosttype/hostmodel to "unknown" and zero all numeric attrs, then update resvals and slots — prevents stale capacity from being visible while the host is down - restore_worker(): apply the same attr reset on WAL recovery so restored-but-unavailable workers advertise no capacity until reconnect; also remove dead calloc() that was immediately overwritten by makeWorker - Extract reset_hostattrs_unknown() helper to eliminate copy-paste - Define XCE_LOST_AND_FOUND_NAME constant in config_repl.h; replace all six raw "lost_and_found" string literals across config_repl.c and dataex.c
This commit is contained in:
parent
2e2aaea78c
commit
1599d06bc4
6 changed files with 79 additions and 56 deletions
|
|
@ -369,16 +369,26 @@ int add_worker(void* cls, endpoint_t* ep, const char* host, hostattrs_t* attrs)
|
|||
return idx;
|
||||
}
|
||||
|
||||
static void reset_hostattrs_unknown(hostattrs_t* a)
|
||||
{
|
||||
dereference(a->hosttype);
|
||||
a->hosttype = makeString("unknown");
|
||||
dereference(a->hostmodel);
|
||||
a->hostmodel = makeString("unknown");
|
||||
a->cpufactor = 0;
|
||||
a->maxcpus = 0;
|
||||
a->maxmem = 0;
|
||||
a->maxswap = 0;
|
||||
a->maxtmp = 0;
|
||||
a->ndisks = 0;
|
||||
}
|
||||
|
||||
int restore_worker(void* cls, xce_worker_t host)
|
||||
{
|
||||
cluster_t* c = (cluster_t*)cls;
|
||||
int idx = 0;
|
||||
worker_t* w = NULL;
|
||||
|
||||
w = calloc(1, sizeof(*w));
|
||||
if (w == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
w = makeWorker(c->workermgr, &host);
|
||||
if (w == NULL) {
|
||||
return -errno;
|
||||
|
|
@ -386,6 +396,8 @@ int restore_worker(void* cls, xce_worker_t host)
|
|||
|
||||
lock(w, RTTI_LOCK_WRITE);
|
||||
|
||||
if (w->host.attrs != NULL)
|
||||
reset_hostattrs_unknown(w->host.attrs);
|
||||
add_hostattrs_resvals(c, w);
|
||||
idx = w->idx;
|
||||
w->host.status |= XCE_WORKER_UNAVAIL;
|
||||
|
|
@ -527,6 +539,12 @@ int mark_worker_unavail(cluster_t* c, worker_t* w)
|
|||
if (w->host.dead_since == 0)
|
||||
w->host.dead_since = time(NULL);
|
||||
|
||||
if (w->host.attrs != NULL) {
|
||||
reset_hostattrs_unknown(w->host.attrs);
|
||||
add_hostattrs_resvals(c, w);
|
||||
set_host_slots(c, w, 0);
|
||||
}
|
||||
|
||||
xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_WORKER, HOOK_AFTER_EVENT,
|
||||
HOOK_DETAIL_WORKER_DEAD, c, w);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue