myxce/src/include/typemap.h
Rongsong Shen dcb1b4fe25 feat: P0-2a C-side plumbing for host control
Add the full call chain for host control operations from the Go API
server through the C library to the controller:

- schema/controller.capnp: HostControl struct + hostctrlmsg @21
  in Request.body union
- include/typemap.h: xce_hostctrl_t* hostctrlmsg in body union
  (placed after @20 clrpreasonmsg, matching capnp ordinal)
- include/client.h, xceapi.h, request.h: declarations for
  xcecli_hostctrl, xce_hostctrl, xce_hostctrl_req
- lib/client.c: xcecli_hostctrl (validate + delegate to xce_hostctrl)
- lib/xceapi.c: xce_hostctrl (validate ctx state + send + wait reply)
- lib/request.c: xce_hostctrl_req (validate hostname/empty/nil,
  accept only HOST_OPEN/HOST_CLOSE, reject HOST_TAG/UNTAG)
- lib/helper.c: Request_body_hostctrlmsg cases in
  xce_request_body() and xce_request_msg_name()
- controller/cluster.c: OPCode_hostcontrol dispatch
- controller/include/cluster.h: do_hostcontrol_op declaration
- controller/worker.c: do_hostcontrol_op + fix pre-existing
  goto-clean bug in worker_ctrl that leaked write lock and
  reference on HOST_OPEN/HOST_CLOSE no-op paths

TDD: 8 xce_hostctrl_req validation tests (null ep, null ctrl,
null/empty hostname, HOST_DO_NONE no-op, HOST_TAG/UNTAG reject,
negative action reject, HOST_OPEN/CLOSE accept via xce_request).

116/116 xcelib tests pass. CGO_ENABLED=0 Go backend tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 07:46:41 +00:00

203 lines
4.8 KiB
C

#if !defined(_TYPEMAP_H_)
#define _TYPEMAP_H_ 1
#include <stdint.h>
#include "clusterconfig.h"
#include "xce/types.h"
typedef struct {
char* resname;
char* hostname;
} xce_reskey_t;
typedef struct {
int type;
union {
uint64_t jobid;
char* wname;
xce_reskey_t* reskey;
} condition;
} xce_match_t;
typedef struct {
int table;
int nrows;
void* rows;
} dataset_t;
typedef struct {
int role;
int data_which;
union {
hostattrs_t* attrs;
} data;
} xce_joindata_t;
typedef struct {
char* clustername;
int n_confvars;
xce_config_t** confvars;
int n_resources;
xce_resource_t** resources;
int n_queues;
xce_queue_t** queues;
int n_ugroups;
xce_group_config_t** ugroups;
int n_hgroups;
xce_group_config_t** hgroups;
int nresvals;
xce_val_with_idx_t** resvals;
int nlimits;
xce_limit_config_t** limits;
int nhproviders;
scaler_config_t** hproviders;
} xce_conf4sched_t;
typedef struct {
char* clustername;
int n_confvars;
xce_config_t** confvars;
} xce_conf4worker_t;
typedef struct {
int data_which;
union {
xce_conf4sched_t* conf4sched;
xce_conf4worker_t* conf4worker;
cluster_config_t* clusterconfig;
} data;
} xce_configdata_t;
typedef struct {
int n_total;
int pos;
int count;
xce_job_t** jobs;
} xce_jobs_data_t;
typedef struct {
int n_total;
int pos;
int count;
xce_worker_t** workers;
} xce_workers_data_t;
typedef struct {
int n_total;
int pos;
int count;
xce_resource_t** resources;
} xce_resource_data_t;
typedef struct {
int n_total;
int pos;
int count;
xce_resval_t** vals;
} xce_resval_data_t;
typedef struct {
int count;
xce_resval_t** vals;
} xce_resval_list_t;
typedef struct {
uint64_t jobid;
int npids;
int* pids;
int npgids;
int* pgids;
int count;
xce_rusage_t** usages;
} xce_job_rusages_t;
typedef struct {
int table;
union {
xce_jobs_data_t* jobs;
xce_workers_data_t* workers;
xce_resource_data_t* resources;
xce_resval_data_t* resvals;
} data;
} xce_data_t;
typedef struct {
int table;
xce_match_t* condition;
} xce_get_t;
typedef struct {
int event;
union {
job_pidinfo_t* pidinfo;
job_failinfo_t* failinfo;
job_failinfo_t* dispatchfail;
xce_jobfinish_t* finishinfo;
uint64_t sched_start_job;
uint64_t sched_exit_job;
uint64_t sched_fail_job;
xce_job_t* sched_update_job;
xce_resval_list_t* sched_update_resvals;
uint64_t stopped_job;
uint64_t resumed_job;
xce_ckptinfo_t* ckptinfo;
xce_queue_t* sched_update_queue;
xce_task_pidinfo_t* taskinfo;
xce_task_failinfo_t* taskfailinfo;
xce_task_finish_t* taskfinish;
uint64_t pdone_job;
xce_job_rusages_t* sched_job_rusages;
xce_job_t* update_job;
} data;
} xce_notify_data_t;
typedef struct {
int table;
union {
xce_resval_list_t* resvals;
xce_job_rusages_t* jobrusages;
} data;
} xce_update_data_t;
typedef struct {
uint64_t seq;
uint32_t opcode;
int32_t status;
int data_which;
union {
char* debugmsg;
uint64_t jobid;
xce_data_t* getdata;
xce_clusterconf_t* clusterconf;
} data;
} xce_reply_t;
typedef struct {
uint32_t opcode;
uint64_t seq;
xce_peerinfo_t* from;
int body_which;
union {
xce_reply_t* replymsg;
char* hellomsg;
xce_joindata_t* joinmsg;
xce_configdata_t* configpushmsg;
xce_data_t* pushmsg;
xce_get_t* getmsg;
dataset_t* datamsg;
xce_job_dispatch_t* dispatchmsg;
xce_job_exec_t* jobstartmsg;
xce_notify_data_t* notifymsg;
xce_job_submit_t* jobsubmsg;
xce_update_data_t* updatemsg;
xce_jobctrl_t* jobctrlmsg;
xce_queuectrl_t* queuectrlmsg;
xce_taskrun_t* runtaskmsg;
xce_preason_set_t* preasonmsg;
xce_clear_reason_t* clrpreasonmsg;
xce_hostctrl_t* hostctrlmsg;
} body;
} xce_request_t;
#endif