feat(controller-peers-env-fallback): flush the controller's log before every early exit (task 2.2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-10-03 06:04:19 +00:00
parent 7a90af089c
commit 25e2807355
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
3 changed files with 47 additions and 1 deletions

View file

@ -29,7 +29,7 @@
- Done when the full controller suite (including the HA and listener tests) passes unchanged
- _Requirements: 1.6_
- [ ] 2.2 Flush the controller's log before every early exit
- [x] 2.2 Flush the controller's log before every early exit
- Add a regression-script case first: a controller run with scratch work, certificate and log paths stops at the certificate pre-flight, and its last startup line (today's "No --peers flag" line) must already be in the log file. The loss is a race with the log's background writer, so the case repeats the run 20 times and fails if any run is missing the line; run it before the fix and record whether it failed (if no run fails, note that the race did not reproduce here and keep the case as a regression guard)
- Flush the log before every early return after the log is opened: name lookup failure, lock init failure, `--peers` parse error, even candidate count, and the certificate pre-flight; flushing is a no-op before the log is opened and safe to repeat
- Done when, after rebuilding the controller, the controller suite passes and that case shows the line in the log file in all 20 runs
@ -132,3 +132,5 @@
- (1.3 → 3.3) `start_bg`/`run_to_completion` feed stdin from `/dev/null`, but `xce_test` reads its script only from stdin; add an optional stdin file to `run_to_completion` (e.g. `RUN_STDIN`) rather than the `sh -c 'exec "$0" --norc <"$1"'` workaround.
- (1.3 → 3.2) The worker's early "HA cluster config"/"No --peers flag" lines go to stdout before its log file is set up; confirm they are not stdio-buffered when stdout is a file (else `wait_for_line` on stdout times out while it runs) — wait for exit or use line buffering if so.
- (1.3) Drop the file-wide `shellcheck disable=SC2329,SC2034` once cases call the helpers, so real unused-variable warnings surface.
- (2.2) The tlog early-exit race did not reproduce on this machine (0/20 before the fix, 0/200 ad hoc); `case_controller_log_flushed_on_early_exit` is kept as a regression guard, not proof of the fix.
- (2.2 → 2.3) That case matches the text "No --peers flag; running as single-node primary"; when 2.3 extends the line (1.8), keep that text intact or update the case's pattern.