No description
Find a file
lei.chen fc33a5da16 admin-plane breakpoint 2: YAML resourcemap wiring + queue payload deep-copy
Breakpoint 2 of the admin-plane gaps (YAML flag/resourcemap wiring), plus
the queue payload ownership fix that the t1 controller segfault of
2026-10-23 12:41:13 traced to.

1. YAML resourcemap wiring (admin-plane-gaps 1.10):
   - schema: Resource.distributions @8 / hostBased @9 uncommented --
     resourcemap had no wire destination at all before this.
   - resobj.c: resobj_init's #if 0 stub replaced with a real deep copy
     (distributions + hbased_defined); resobj_destroy frees them. Deep
     copy is mandatory: the source is myconf->cluster_config, which
     keeps owning and later frees its tree.
   - controller: reconcile_config_resources + seed_sharedinst_from_config
     (cluster.c) seed c->sharedinst for SHARED|GLOBAL resources whose
     distribution carries a value (the license-pool shape), from both
     config_activate_committed paths, ahead of the conf4sched push.
   - xceadmin: mapping.py maps resourcemap -> distributions (only the
     location:[all]+value shape sets SHARED|GLOBAL), build.py renders
     shared=true/distributions; golden expected.bin regenerated.

2. xcesched_push_configs resval double free (t1 12:39:52 abort): the
   seeded push freed the resval entries AND the backing array via
   free_name_val_list, then xlist_fini freed the same array again.
   Detach xreslist before the FREEUP/xlist_fini block (same ownership
   class bug-1506 fixed in sched_worker_change). Latent since inception:
   every pre-1.10 push ran with nresvals==0 and never armed it.

3. queue payload deep-copy (t1 12:41:13 encode_Threshold_list segfault):
   queue_init (create) MOVED the definition's users/hosts/thresholds/
   window payloads out, and queue_refresh_def MOVED them out again --
   but reconcile_config_queues runs MORE THAN ONCE over the same
   cluster_config object (boot: pre-election activation AND phase2's
   build_queues), so the second pass refreshed live queues from the
   drained definition: thresholds became the poisoned (count>0,
   array=NULL) pair, the generated encode_Threshold_list has no NULL
   guard, and the next queue/worker push died on the NULL base.
   Both paths now deep-copy (queue_init and queue_refresh_def); the
   definition keeps its payloads, (NULL/0) genuinely means "no list in
   this config", and reconcile is idempotent. New dup_group_config
   helper in utils.c (the generated code has no GroupConfig dup).
   Mirrors resobj_init's distributions deep-copy and worker.c
   apply_join_state's dup pattern.

4. UT: test_reconcile_thresholds_survive_second_pass drives a triple
   reconcile of a threshold-carrying queue and asserts definition
   intactness plus a real encode_QueueConf -> wire -> decode round
   trip; new test_config_resource_reconcile.c covers seed/deep-copy/
   non-seed classes and idempotent re-seed.

Suites: controller_unit_test 1348/1348, sched_push 4, sched_worker_change 3,
apiserver_push 2, host_runusage 11, xcelib 759, xcealloc_oom 11,
99 scheduler binaries, all worker + harness suites, xceadmin pytest 375.
t1 E2E: boot double-reconcile clean, scheduler rejoin + full conf4sched
push applied, recovered crash-era PEND job reached DONE, 30-job saturation
flow (24 RUN + 6 PEND -> DONE), live gen-12 config activation with
re-push to the connected scheduler -- no crash, all four daemons healthy.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-10-23 14:29:29 +00:00
.claude build: recalibrate asan per-job memory budget 1536MB -> 512MB 2026-10-21 15:38:46 +00:00
.kiro docs(spec): project-config: a built-in default project always exists 2026-10-13 07:17:22 +00:00
.wolf bug-1971: fix_commits field via buglog.py status 2026-10-22 08:08:44 +00:00
docs docs: mark P1 PEND-reason cluster verification done (070e9992) 2026-09-01 15:26:52 +00:00
issues chore(scheduler-allocator-runner): validation passed; new_requirements item 4 resolved (task 5.2) 2026-09-30 10:11:10 +00:00
raft chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
scripts build: remove nix dependency layer -- apt system libs + meson wrap subprojects 2026-10-20 18:04:22 +00:00
src admin-plane breakpoint 2: YAML resourcemap wiring + queue payload deep-copy 2026-10-23 14:29:29 +00:00
.clang-format reformat code and job array 2025-11-07 16:14:27 +08:00
.gitignore admin-plane breakpoint 2: YAML resourcemap wiring + queue payload deep-copy 2026-10-23 14:29:29 +00:00
.mcp.json chore(mcp): use XCE_API_KEY env var in xce-scheduler MCP config 2026-08-12 08:41:19 +00:00
.opencode.json checkpoint: bug-851 root cause + raft TLA+ conformance spec family 2026-06-21 14:02:15 +00:00
admin-plane-gaps.md admin-plane breakpoint 2: YAML resourcemap wiring + queue payload deep-copy 2026-10-23 14:29:29 +00:00
CLAUDE.md docs(steering): resource decision and question log (PR-1..3 proposals, R/P/N items) 2026-10-12 04:00:47 +00:00
DEPS.md build(packaging): bundle ttyd prebuilt; record license-compliance notes (DEPS.md) 2026-10-21 03:33:10 +00:00
gaps.md scheduler audit P1: picker hook validation + rejection WARNs + sim bootstrap by name 2026-10-22 14:05:38 +00:00
Makefile build: remove nix dependency layer -- apt system libs + meson wrap subprojects 2026-10-20 18:04:22 +00:00
README.md docs(readme): replace nix build instructions with the de-nix meson flow 2026-10-21 03:44:43 +00:00

1. commit 规则

  • 每个人 fork 自己的 branch, 从自己的 branch 做 PR,review 完再 commit

2. code format

2.1. C

推荐使用 clang-format,公共配置放在源码里面 xce/.clang-format

(理论上直接使用源码里面 xce/.clang-format 文件格式不会变)

2.1.1. vscode 可以在配置中加上如下内容

"C_Cpp.clang_format_style": "WebKit",
"C_Cpp.clang_format_fallbackStyle": "WebKit",

2.1.2. vim & emacs

clang-format -style="{BasedOnStyle: webkit}" -i XX.c

2.2. golang

使用默认 gofmt

3. build environment and build (example of ubuntu)

构建不依赖 nix:直接在 Ubuntu(24.04 基线)上用 apt 系统库 + meson wrap subprojects 构建。完整的依赖清单(工具链 + 11 个 apt 库的版本下限 + 6 个随仓库 提交的 wrap subproject 源码闭包)见 DEPS.md。

3.1 build environment

一次性安装构建工具链与系统库(与 CI 的 scripts/ci-ubuntu.sh 完全一致):

sudo apt-get update
# 工具链
sudo apt-get install -y build-essential pkg-config ninja-build \
    python3 python3-pip python3-venv git
# meson >= 1.5(Ubuntu 24.04 自带 1.3,pip 原地升级)
sudo apt-get install -y meson
meson --version | grep -qE '^1\.[5-9]' || pip3 install --break-system-packages 'meson>=1.5'
# cap'n proto(schema 编译器 + pycapnp 链接的 C++ 运行时)
sudo apt-get install -y capnproto libcapnp-dev
# C 库(DEPS.md "apt 可直接安装" 表)
sudo apt-get install -y libuv1-dev libssl-dev libedit-dev libsqlite3-dev \
    libhwloc-dev libcgroup-dev libtirpc-dev libcyaml-dev libyaml-dev \
    zlib1g-dev libsystemd-dev
# Go(apiserver/xcecli 依赖已全部 vendored,构建离线)
sudo apt-get install -y golang-go

其余依赖(c-capnproto、librtti、struct2json、tinylog、unity、packcc)不在系统里装—— 它们以 meson wrap subproject 的形式提交在 src/subprojects/(源码闭包),meson 配置时自动拉取/构建,无需手动处理。

3.2 checkout source code

git clone ssh://forgejo@gitea.shenrs.eu/rshen/xce.git
cd xce

(参考第 1 节,fork 自己的 branch 再提交 PR)

3.3 build (for daily develop)

日常开发直接用 src/tools/xce-build.sh(若在 Claude Code 中开发,对应 /xce-build skill)。脚本开头有依赖预检(缺工具/缺库时报出具体的 apt 包名,而不是构建中途的 晦涩报错),然后执行 meson setup / meson compile,asan profile 下还会自动跑测试:

cd xce/src

tools/xce-build.sh              # 全部组件 + 全部测试 (asan profile, 输出到 xce.build/)
tools/xce-build.sh controller   # 只构建/测试 controller (lib + controller + xce_test)
tools/xce-build.sh worker       # 只构建 worker
tools/xce-build.sh scheduler    # 只构建/测试 scheduler
tools/xce-build.sh apiserver    # 只构建/测试 apiserver + xcecli (Go)

支持三种 profile(tools/xce-build.sh [component] [profile]):

  • asan(默认):debug + AddressSanitizer,输出目录 xce.build/,会运行测试
  • debug:-O0 -g3 无 sanitizer,输出目录 build.dbg/,仅编译,用于 gdb 调试
  • release:-O3 无 sanitizer,输出目录 build.release/,仅编译,用于 soak/性能测试

注意:单组件构建默认会先 rm -rf 对应的 build 目录再重新配置,若同一目录下已有其他 组件的产物会被清掉;需要在同一目录下累积多个组件时加 --incremental(增量 reconfigure,不清空目录;capnp 生成目标存在未修的依赖边缺失,增量构建若结果可疑 请退回全量重建,见脚本内 bug-1565 注释)。

也可以手动执行底层的 meson 命令(xce-build.sh 是对下面步骤的封装):

cd xce/src

# generate build configuration (debug + address sanitizer)
meson setup xce.build --buildtype=debug -Db_sanitize=address

# build
meson compile -C xce.build

# The generated files will be in xce.build/

3.3.1 更新 Go 依赖(vendor 维护)

Go 模块(frontend/apiserver、frontend/xcecli、 autoscaler/providers/baidu/src/bcctool)的依赖以 vendor/ 目录的形式提交进仓库, 构建时 tools/go_build 使用 GOFLAGS=-mod=vendor、GOPROXY=off 完全离线编译。

修改了某个模块的 go.mod / go.sum(新增、升级、删除依赖)后,重新生成对应模块 的 vendor/ 并提交(普通环境即可,无需任何特殊 shell):

cd xce/src/frontend/apiserver   # 其他两个模块同理
go mod tidy
go mod vendor
git add go.mod go.sum vendor

3.4 package (tarball 分发)

产品分发形态是自包含 tarball(daemon + CLI + $ORIGIN RPATH 的 bundled 非基础库

  • systemd unit 样例 + configs/schema + ttyd),打包规则见 src/tools/xce-package.sh 头部注释与 DEPS.md "运行期 bundle 规则":
cd xce/src

tools/xce-build.sh all release        # 先出 release 构建(build.release/)
tools/xce-package.sh                  # 默认从 build.release/ 打到 dist/
# 或显式指定: tools/xce-package.sh build.release dist

产物:dist/xce-<version>-<commit>-<fingerprint>-linux-x86_64.tar.gz。目标机上:

tar -xzf xce-*.tar.gz && cd xce-*/
sudo ./install.sh                      # 默认装到 /opt/xce,PREFIX=... 可覆盖

3.5 CI

scripts/ci-ubuntu.sh 在裸 Ubuntu 24.04 容器里跑完整流水线(装依赖 → asan 全量 构建+测试 → release 构建 → 打 tarball smoke),与客户环境同构:

bash scripts/ci-ubuntu.sh

4. misc

4.1. Windows remap ctrl and alt key

create a reg file, e.g. remapkey.reg

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,05,00,00,00,38,00,1d,00,1d,00,38,00,38,e0,1d,e0,1d,e0,38,e0,00,00,00,00

then double click remapkey.reg to import it. Restart OS.