feat(build-time-versioning): worker --version and startup log

Worker uses plain getopt_long(), not argp, so it has no free --version
handling like controller/scheduler. Adds a long-only OPT_VERSION=257
option and a handling case that computes xce_compose_version() into a
static buffer and returns before any startup work (check_user()/
xcecd_init/xcecd_start). Both startup INFO log branches (--peers and
no-peers) extended to log the identical buffer.

Live-verified: --version and both startup-log branches are
byte-identical (captured via a real daemon run under sudo).

Also updates bug-1519 (pre-existing, unrelated ASAN "Joining already
joined thread" abort during worker shutdown): independently reproduced
under real root during this task's review, refining its prior "never
reproduced under real root" note -- not a userns/unshare artifact, still
unfixed, does not affect this task's code path.

Task 3.3/13 of build-time-versioning. This closes out the "Core: C
daemon version display" phase (tasks 3.1-3.3).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-08-20 11:47:12 +00:00
parent 88649a0462
commit bc5c669b94
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
3 changed files with 41 additions and 15 deletions

View file

@ -40,10 +40,10 @@
- _Boundary: controller/main.c, scheduler/main.c, controller/testsuite/test.c_
- _Depends: 3.1_
- [ ] 3.3 (P) Worker: add --version and startup log line
- Add a long-only `--version` option to worker's `getopt_long()` option table and a handling case that prints the same macro output and exits before any other startup work
- Add the version string to worker's existing first startup INFO log line (its own `"HA cluster config..."` line)
- Observable: `xcecd --version` prints commit id + build time and exits without starting the daemon; the startup log's first lines include the identical two values
- [x] 3.3 (P) Worker: add --version and startup log line
- Added `OPT_VERSION=257` (long-only, beyond ASCII range, no collision with `"n:l:vh"`/`OPT_PEERS=256`); handling case computes `xce_compose_version()` into a `static char version_buf[128]` and returns before any startup work (`check_user()`/logdir/`xcecd_init`/`xcecd_start`)
- Both startup INFO log branches (`--peers` and no-`--peers`) extended to log the same buffer
- Observable confirmed live (independently re-verified by review): `xcecd --version` prints and exits; both startup log branches (captured via a real `sudo` daemon run) are byte-identical to `--version` output
- _Requirements: 1.1, 1.2, 2.1, 2.2, 3.1, 3.2, 4.3_
- _Boundary: worker/main.c_
- _Depends: 3.1_