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:
parent
7a90af089c
commit
25e2807355
3 changed files with 47 additions and 1 deletions
|
|
@ -300,6 +300,41 @@ on_exit() {
|
|||
# them with add_case, in the order they should run.
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
|
||||
# Task 2.2 (Req 1.3): the controller logs through tlog's background writer,
|
||||
# so a line logged just before an early return is only in the log file if the
|
||||
# return flushes the log first. With an empty --certdir and no --peers (and
|
||||
# no XCE_CONTROLLER_PEERS) the controller stops at the certificate pre-flight
|
||||
# right after its "No --peers flag" line. The loss is a race, so repeat the
|
||||
# run and fail if any single run is missing the line.
|
||||
FLUSH_RUNS=20
|
||||
case_controller_log_flushed_on_early_exit() {
|
||||
local i d missing=0
|
||||
for i in $(seq 1 "$FLUSH_RUNS"); do
|
||||
d="$(new_scratch controller-flush)"
|
||||
mkdir -p "$d/work" "$d/certs"
|
||||
run_to_completion "$d" 10 -u XCE_CONTROLLER_PEERS \
|
||||
"$CONTROLLER_BIN" --myname ctrl-flush --workdir "$d/work" \
|
||||
--certdir "$d/certs" --logfile "$d/controller.log"
|
||||
if [ "$RUN_RC" -eq 0 ] || [ "$RUN_RC" -ge 124 ]; then
|
||||
red " run $i: expected the certificate pre-flight to stop the controller, exit status $RUN_RC"
|
||||
_show_tail "$d/stderr"
|
||||
return 1
|
||||
fi
|
||||
if ! grep -Eq -- 'No --peers flag; running as single-node primary' \
|
||||
"$d/controller.log" 2>/dev/null; then
|
||||
missing=$((missing + 1))
|
||||
red " run $i: last startup line missing from $d/controller.log"
|
||||
fi
|
||||
done
|
||||
if [ "$missing" -ne 0 ]; then
|
||||
red " $missing/$FLUSH_RUNS run(s) lost the last startup line"
|
||||
return 1
|
||||
fi
|
||||
log " all $FLUSH_RUNS runs had the last startup line in the log file"
|
||||
}
|
||||
add_case case_controller_log_flushed_on_early_exit \
|
||||
"controller: log flushed before the certificate pre-flight exit ($FLUSH_RUNS runs)"
|
||||
|
||||
|
||||
# ════════════════════════════════════════════════════════════════════════════
|
||||
# main
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue