Merge nobs/feed-sigpipe2 (nobs MiniMax M3; Claude review: the test did not reproduce the bug and printf still printed its error; fixed on top)
Some checks failed
Some checks failed
This commit is contained in:
commit
291620f5d5
2 changed files with 32 additions and 9 deletions
|
|
@ -129,6 +129,12 @@ page_on_feed() {
|
|||
page_unit_active() { systemctl is-active --quiet "$FLY_PAGE_SERVICE" 2>/dev/null; }
|
||||
|
||||
old_invocation=""
|
||||
# Print to stdout, exiting quietly once the reader has gone (`fly-feed status | head -1`).
|
||||
# Under `pct exec` SIGPIPE is ignored, so a write to a closed pipe fails with EPIPE and bash's
|
||||
# printf/echo print "write error: Broken pipe": silence that one write and stop printing.
|
||||
say() {
|
||||
printf '%s\n' "$*" 2>/dev/null || exit 0
|
||||
}
|
||||
# Wait for a NEW flysim invocation to be healthy and the feed to be flowing in `via` mode.
|
||||
healthy() {
|
||||
local via="$1" deadline
|
||||
|
|
@ -195,24 +201,24 @@ status_report() {
|
|||
local conf run edge_state url
|
||||
conf="$(configured)"
|
||||
run="$(running)"
|
||||
echo "configured: ${conf}"
|
||||
echo "running: ${run}"
|
||||
say "configured: ${conf}"
|
||||
say "running: ${run}"
|
||||
if [ "$run" != stopped ] && [ "$run" != unknown ] && [ "$conf" != "$run" ] && [[ "$conf" != invalid:* ]]; then
|
||||
echo " fly.env and the running flysim disagree: the next start of ${FLY_SERVICE} applies ${conf} (fly-feed ${conf} does it now)"
|
||||
say " fly.env and the running flysim disagree: the next start of ${FLY_SERVICE} applies ${conf} (fly-feed ${conf} does it now)"
|
||||
fi
|
||||
edge_state="$(systemctl is-active "$FLY_EDGE_SERVICE" 2>/dev/null || true)"
|
||||
echo "${FLY_EDGE_SERVICE}: ${edge_state:-unknown}"
|
||||
say "${FLY_EDGE_SERVICE}: ${edge_state:-unknown}"
|
||||
url="$(metrics_url "$run")"
|
||||
if [ "$run" = bus ]; then
|
||||
if curl -fsS -o /dev/null --max-time 5 "${FLY_EDGE_METRICS_URL}/healthz" 2>/dev/null; then
|
||||
echo "edge healthz: ok"
|
||||
say "edge healthz: ok"
|
||||
else
|
||||
echo "edge healthz: NOT OK ($(curl -sS --max-time 5 "${FLY_EDGE_METRICS_URL}/healthz" 2>&1 | head -c 100))"
|
||||
say "edge healthz: NOT OK ($(curl -sS --max-time 5 "${FLY_EDGE_METRICS_URL}/healthz" 2>&1 | head -c 100))"
|
||||
fi
|
||||
echo "edge snapshot age: $(metric "$url" fly_edge_snapshot_age_seconds) s; bus lost: $(metric "$url" fly_edge_bus_lost_total); bind failures: $(metric "$url" fly_edge_bind_failures_total); decode failures: $(metric "$url" fly_edge_decode_failures_total)"
|
||||
say "edge snapshot age: $(metric "$url" fly_edge_snapshot_age_seconds) s; bus lost: $(metric "$url" fly_edge_bus_lost_total); bind failures: $(metric "$url" fly_edge_bind_failures_total); decode failures: $(metric "$url" fly_edge_decode_failures_total)"
|
||||
fi
|
||||
echo "feed clients: $(metric "$url" fly_feed_clients) (counters of the ${run} server); frames sent: $(metric "$url" fly_frames_sent_total)"
|
||||
if [ -f "$FEED_LOG" ]; then echo "last switch: $(tail -n1 "$FEED_LOG")"; fi
|
||||
say "feed clients: $(metric "$url" fly_feed_clients) (counters of the ${run} server); frames sent: $(metric "$url" fly_frames_sent_total)"
|
||||
if [ -f "$FEED_LOG" ]; then say "last switch: $(tail -n1 "$FEED_LOG")"; fi
|
||||
}
|
||||
|
||||
[ $# -ge 1 ] || usage
|
||||
|
|
|
|||
|
|
@ -1659,6 +1659,8 @@ mkdir -p "$ff_dir/bin" "$ff_dir/release" "$ff_dir/proc/4242" "$ff_dir/run"
|
|||
cat > "$ff_dir/bin/systemctl" <<'FFSTUB'
|
||||
#!/usr/bin/env bash
|
||||
echo "$*" >> "$FF_DIR/systemctl.log"
|
||||
# FF_SLOW: answer is-active late, as a real systemctl does, so a reader can leave in between
|
||||
[ -n "${FF_SLOW:-}" ] && [ "$1" = is-active ] && sleep 0.3
|
||||
case "$1" in
|
||||
restart) n=$(( $(cat "$FF_DIR/invocation" 2>/dev/null || echo 1) + 1 )); echo "$n" > "$FF_DIR/invocation"
|
||||
# the new flysim's environment is whatever fly.env says now
|
||||
|
|
@ -1720,6 +1722,21 @@ else
|
|||
fail "fly-feed status wrong: $ff_out"
|
||||
fi
|
||||
|
||||
# `fly-feed status | head -1` under `pct exec`, which runs commands with SIGPIPE ignored: every
|
||||
# write after head exits fails with EPIPE, and bash prints "write error: Broken pipe" unless
|
||||
# fly-feed stops printing quietly (seen live on 2026-10-02). Reproduce both conditions: SIGPIPE
|
||||
# ignored (inherited by the script) and a reader that leaves after the first line.
|
||||
ff_reset direct direct
|
||||
FF_ARGS=(status)
|
||||
ff_pipe_err="$(mktemp)"
|
||||
( trap '' PIPE; export FF_SLOW=1; fly_feed 2>"$ff_pipe_err" ) | head -1 >/dev/null || true
|
||||
if [ ! -s "$ff_pipe_err" ]; then
|
||||
pass "fly-feed status | head -1 with SIGPIPE ignored: nothing written to stderr"
|
||||
else
|
||||
fail "fly-feed status | head -1 wrote to stderr: $(cat "$ff_pipe_err")"
|
||||
fi
|
||||
rm -f "$ff_pipe_err"
|
||||
|
||||
ff_reset direct direct
|
||||
FF_ARGS=(bus)
|
||||
if fly_feed && [ "$(grep -c '^FLY_FEED_VIA=' "$ff_env")" = 1 ] && grep -qx 'FLY_FEED_VIA=bus' "$ff_env" \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue