Update task tracker: P0-2a is done (15 files, 8 TDD tests, 116/116 pass). P0-2b (Go-side ControlHost + allFlag race fix) is now unblocked. Also fixed pre-existing goto-clean bug in worker_ctrl that leaked write lock + reference count on HOST_OPEN/HOST_CLOSE no-op paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7.3 KiB
7.3 KiB
API Server Backend Enhancement — Task Tracker
Status Legend
- Completed
- Pending
- [>] In Progress (blocked)
P0-1: Handle Cluster Config Push
-
#1 P0-1a: Add HostConfig + Cluster fields to models
models/clusters.go— AddedHeartbeatInterval,Vcpus,InactiveHeartbeatCounttoClusterInfomodels/hosts.go— ChangedHostStateStr(0)from"OK"to"UNKNOWN"models/clusters_test.go— New: verifies new fields serialize + existing fields unchangedmodels/hosts_test.go— New: verifiesHostStateStrfor zero, flags, non-flag, combined- All 15 tests passing
-
#2 P0-1b: Add pure Go conversion functions + TDD tests
backend/convert_pure.go— AddedrawHostConfigData+rawHostConfigToModel(),rawClusterData+rawClusterToModel()backend/convert_test.go— 8 new table-driven tests: zero-value ints, empty strings, normal values, worker/config-sourced field isolationTODO(dispatchwindow)comment added per plan specDisptWindowguard test added to catch accidental future CGO layer changes- All 26 backend tests passing
-
#3 P0-1c: Add CGO conversion layer in convert.go
backend/convert.go— AddedcHostConfigToModel(),cClusterConfHostConfigs(),cClusterConfToClusterInfo()cResdefToModelintentionally skipped —xce_resdef_tdoesn't exist in C codebase andResourceInfohas no store/consumer (YAGNI); existingcResourceToModel→ResourceDefinitionInfoalready handles config pushcClusterConfResourcesalready existed — no change needed- CGO compilation verified passing
- All unit tests still passing
-
#4 P0-1d: Implement handlers with partial merge + TDD
backend/notification.go— AddedOnClusterUpdated(cluster *models.ClusterInfo)andOnHostConfigUpdated(host *models.HostInfo)toNotificationHandlerinterfacebackend/handler.go— Implemented partial-mergeOnClusterUpdated(preserves Version, Status, ControllerName, NumServers, Resources, HostTypes, HostModels, ClusterAdmins),OnHostConfigUpdated(preserves HostStatus, CPUFactor, NumCPUs, NumCores, NumThreads, MaxMem, MaxSwap, MaxTmp, NumDisk, NumRun, NumSSusp, NumUSusp, NumDone, Topology, SchedStop), fixedOnHostUpdated(preserves HostModel, HostType, MaxSlot, DisptWindow via two-valueGet())backend/handler_test.go— 6 new tests: new host, partial merge for each of OnHostConfigUpdated, OnClusterUpdated, OnHostUpdated- All backend tests passing (32 total)
-
#5 P0-1e: Expand handleConfigPush (unblocked)
backend/clib.go— ExpandhandleConfigPush()to callcClusterConfHostConfigs()andcClusterConfToClusterInfo()- Call
gHandler.OnHostConfigUpdated()per host config,gHandler.OnClusterUpdated()for cluster settings
P0-2: Host Control via Backend
-
#6 P0-2a: C-side plumbing for host control
schema/controller.capnp— AddedHostControlstruct +hostctrlmsg @21include/typemap.h— Addedxce_hostctrl_t* hostctrlmsg;to body union (after @20 clrpreasonmsg, matching capnp ordinal)include/client.h— Addedxcecli_hostctrl()declarationinclude/xceapi.h— Addedxce_hostctrl()declarationinclude/request.h— Addedxce_hostctrl_req()declarationlib/client.c— Implementedxcecli_hostctrl()lib/xceapi.c— Implementedxce_hostctrl()withcbuf_get()waitlib/request.c— Implementedxce_hostctrl_req()(validates HOST_OPEN/HOST_CLOSE only, rejects HOST_TAG/UNTAG)lib/helper.c— AddedRequest_body_hostctrlmsgcase toxce_request_body()+xce_request_msg_name()controller/cluster.c— AddedOPCode_hostcontrolcase →do_hostcontrol_op()controller/worker.c— Implementeddo_hostcontrol_op()callingworker_ctrl(); fixed pre-existinggoto cleanbug that leaked write lock + reference countcontroller/include/cluster.h— Declareddo_hostcontrol_op()lib/testsuite/test_request.c— 8 TDD validation tests (null ep/ctrl/hostname, empty hostname, HOST_DO_NONE no-op, HOST_TAG/UNTAG reject, negative action)- Regenerated capnp via
ninja -C build
-
#7 P0-2b: Implement Go-side ControlHost + fix allFlag race (unblocked)
backend/clib.go— ReplaceControlHost()stub with real implementation viaxcecli_hostctrl()controllers/hosts.go— Fix data race: removevar allFlag bool, return frompreCheckHostControlRequestas localcontrollers/queues.go— Same allFlag data race fix (lines 534-536 / 465)
-
#8 P0-2c: Register routes + RBAC for host control/select
router/routers.go—POST /xce/v1/hosts/control→ RBAChost:control(cluster_admin)router/routers.go—POST /xce/v1/hosts/select→ RBAChost:view(all authenticated)config/rbac.yaml— Addhost:controlandhost:viewaction entries
-
#9 P0-2d: Update stub.go with new function stubs
backend/stub.go— KeepControlHoststub (returnerrNoCGO), addStartHeartbeat(ctx context.Context){},SetHeartbeatInterval(secs int){},EvalSelectForHost(...)returningerrNoCGO,Cleanup(){}- Add
"context"to import block
P1-1: Handle Resource Value Push
- #10 P1-1: Handle resource value push (OPCode_notify)
backend/clib.go— Add CGO val helpers to preamble (xce_val_which,xce_val_i32, etc.)backend/clib.go— AddOPCode_notifycase at top-level switch ingo_push_handler()(NOT insidehandlePush())backend/clib.go— AddhandleNotifyData()forNotifyData_data_schedUpdateResvalsbackend/convert.go— AddcResvalToDistribution()— switch onValue_u_*constants, all 7 cases separate
P1-2: Host Resource Requirement Select
-
#11 P1-2a: C select expression parser (PEG + eval)
include/resreq.h— Replace emptyxce_resreq_select_with expression tree types, add enums, add extern declarationslib/xce_select.peg— New PEG grammar for select boolean expressions (right-recursive)lib/resreq.c— Implementparse_select(),eval_select(),free_select(); updatekill_primary_resreq()lib/meson.build— Addxce_select.pegto explicit source list
-
[>] #12 P1-2b: Go EvalSelectForHost + FilterHostByResReqSelect (blocked by #11)
backend/clib.go— AddEvalSelectForHost()usingcgo.Handlefor callback context, add#include "resreq.h", extern declarations,xce_select_destroyhelpercontrollers/hosts.go— ImplementFilterHostByResReqSelect, updatepreCheckHostRequest()limit from 4094→1024 bytes
P1-3: Heartbeat Keep-Alive
- #13 P1-3: Heartbeat keep-alive implementation
backend/clib.go— AddheartbeatIntervalSecs int32(default 30),SetHeartbeatInterval(),heartbeatFnvar,StartHeartbeat(ctx context.Context)backend/handler.go—OnClusterUpdatedcallsSetHeartbeatInterval(cluster.HeartbeatInterval)after store updatecmd/main.go— Callbackend.StartHeartbeat(ctx)afterbackend.RegisterToBackend(...)
Final
- [>] #14 Build and test verification (blocked by all others)
make testinsrc/frontend/passesninja -C buildfor C components passes- RBAC verification
- Input safety verification (1024-byte limit, 256-host limit)