Repository navigation
Description
What's the problem
What was measured
tier4-kvm job 1194 (phases=all, timeout_minutes=220), commit 6e57bfb01bc567d4dc86581e98c7a05a9a72f07c:
18:51:11.865Z os harness: 391 passed, 4 failed
18:51:11.907Z ==> console from the failed run kept at /tmp/pithead-os-serial.log.failed
19:04:05.178Z == stopping what this job still runs ==
19:04:05.187Z exit 124 (timed out)
bench-ci's wrapper polls kill -0 on the tests/os/run.sh pid, so run.sh itself was still alive for about 13 minutes after it printed its summary. That makes the whole job timed_out rather than failure. The last line run.sh printed comes from its EXIT trap (cleanup in tests/os/lib/core.sh). After that line the trap only runs vm_destroy (virsh destroy and virsh undefine --nvram, in tests/os/kvm-preflight.sh) and rm -f "$DISK" …. One of those is where it sat.
For comparison, job 1151 (commit d572de00) printed the same line and exited 22 seconds later. The difference between the runs: in 1151 the stack phase failed early on host-key checking (#2716), while in 1194 it ran tests/integration/run.sh's full lifecycle and fault-injection legs against the guest before this teardown.
Asks
- Bound and log the teardown: time
virsh destroyandvirsh undefineand print what was still running, so the next occurrence names itself. - Find what keeps the stack-phase guest or
run.shalive at exit (a lingering child, a qemu stuck destroying, or a lock). - Also note the time budget: the harness body took 207 of the 220 minutes, so
--phase allis near the ceiling even without the hang.
what it impacts
Impact is not separately established in the existing report; confirm the affected users or behavior.
How I found it
Discovery details are not separately established in the existing report; preserve and verify the evidence already recorded.
how important is it
Importance has not been assessed explicitly; triage must state the priority and its reason.
acceptance criteria
Acceptance script
This issue has asks rather than an acceptance section, so the goal below is derived from them. A tier4-kvm job that includes the stack phase must end as success or failure, not timed_out. Its teardown must be bounded and must log itself, so a hang names its own cause.
- Ask 1, bound and log the teardown: C2, C3 and C5 locally; B2 and B3 on the bench. The issue names no bound. This script allows 300 s for the whole teardown with both
virshcalls hung. That is under half of the 13 minutes job 1194 lost. - Ask 2, find what keeps the guest or
run.shalive: this can only be found if the hang recurs. C4 checks that a teardown call which runs out its bound lists the two process candidates the issue names: a lingering child ofrun.sh, and the test VM's qemu. A lock has no generic process signature, so it is not checked. - Ask 3, the time budget: the 2026-09-27 owner ruling on GA gate, unfiled: the KVM battery must be green on the SHIPPING cut's tip, and its static half carries a check that cannot fail (#1414) #1651 settled it. The release gate now runs as two tier4-kvm jobs under bench-ci's 240-minute cap. Not checked here.
Done means the script prints ACCEPTED and exits 0 on the PR head with a tier4-kvm job's results. Every check is a mechanical pass or fail, so no judgment call is needed. Paste the script's full output into the PR body.
# save the script below as /tmp/accept_2727.py (outside the repo), then, from the repo root, on Linux
# and NOT on a bench host (the teardown under test may signal processes named after the test VM):
python3 /tmp/accept_2727.py --results DIR
It takes about 3 minutes on a fixed head and about 6 minutes on develop, where C2 waits out its 300 s. It changes no tracked file. C2 to C5 run tests/os/run.sh's own text through bash with three exact lines swapped. DISK= and SERIAL= point into a temporary directory. require_host + require_clean_bench become: start a lingering child, print a verdict, exit 0. So every module run.sh sources is loaded, and its real EXIT handler runs the teardown against a fake virsh first on PATH. In the hung case, virsh destroy and virsh undefine never return and the domain stays listed, as a qemu stuck destroying would leave it. A fake qemu-system-x86_64 -name guest=pithead-os-test,… process runs beside it.
To get DIR from a tier4-kvm job on the PR head whose phases include stack (release-gate group 2: rig,rigmedia,media,fault,reset,image-upgrade,stack):
mkdir -p /tmp/r2727
bench-ci evidence <id>@<head-sha> > /tmp/r2727/evidence.txt
# and save the job's run log (tests/os/run.sh's output and the wrapper's lines after it, as bench-ci
# shows it, with its HH:MM:SS.mmmZ stamps) as /tmp/r2727/run.log
| Check | Passes when |
|---|---|
| C1 | Changes stay in tests/os/, tests/stack/ and docs/dev/, and something under tests/os/ changes. CHANGELOG.md is also allowed. |
| C2 | With virsh destroy and virsh undefine both hung, run.sh's teardown ends within 300 s. On develop it is still running at 300 s and is killed. |
| C3 | That hung teardown prints a line naming virsh destroy with a duration (12 s, 0.4s, 60 seconds, …), and one naming virsh undefine. |
| C4 | That hung teardown's output names the lingering child of run.sh and the VM's qemu process, both by command line. |
| C5 | With a healthy fake virsh, the teardown exits 0 within 60 s and prints both timing lines. |
| C6 | PITHEAD_OS_VM_DESTROY_SELF_TEST=1 bash tests/os/kvm-preflight.sh exits 0, the existing self-test of vm_destroy's refusal. |
| C7 | tests/os/selftest-run-modules.sh passes. It pins core.sh's function list, so a new teardown helper there must be added to it. |
| B1 | DIR/evidence.txt is a tier4-kvm job on HEAD with stack or all in its phases, status completed, and conclusion success or failure, not timed_out. |
| B2 | DIR/run.log has a ==> phase: stack banner and an os harness: verdict line, and after the verdict both the virsh destroy and the virsh undefine timing lines. |
| B3 | In DIR/run.log, the virsh undefine timing line is stamped within 300 s of the verdict line. |
Rules:
- Do not change the script's anchors, bounds or expected outcomes. If a check prints
error(anchor found 0x ...),tests/os/run.shhas moved since this issue was filed. Stop and comment here with the output instead of editing the anchor. - A reviewer re-runs the same script on the head they review, with that head's job. A changed head needs a fresh run and a fresh job.
- The repo's normal gates still apply on top of this:
make testand the adversarial review.
Baseline, run 2026-10-03 on 4598474 (develop): unmodified develop prints NOT ACCEPTED: 2/10 checks pass, with or without a fail fixture. Only C6 and C7 pass. C2 prints still running after 300 s, killed. C3 and C4 find nothing in the hung output. C5 exits 0 after 1 s with no timing line. The fail fixture is a synthetic run log of job 1194's shape: the verdict, then nothing from the teardown until the wrapper's timeout 13 minutes later, with a timed_out evidence block. A throwaway prototype, not committed, printed ACCEPTED: 10/10 checks pass with a pass fixture. That fixture's teardown lines are the prototype's own output from C5's healthy run, after a synthetic stack-phase tail. In kvm-preflight.sh, the prototype ran each virsh call in the background, polled it for up to VM_TEARDOWN_TIMEOUT (60) seconds, and printed teardown: <call> took N s (rc R). When a call ran out its bound, it first printed ps -eo pid,ppid,etime,args, filtered to run.sh's children and qemu processes naming the VM, then killed the call. Its hung run ended in 120 s. Each side was run twice: develop once without a fixture and once with the fail fixture, the prototype twice with the pass fixture.
Hint, not binding: a function, not timeout(1), is what lets the existing _vm_destroy_self_test keep its shell-function virsh stub. timeout would exec a real virsh binary if the host has one. The rm -f "$DISK" … after vm_destroy is the other place the issue says job 1194 could have sat. Nothing here checks it.
Independent re-check, 2026-10-03: a second session re-ran this script in a fresh worktree at 4598474. Develop printed NOT ACCEPTED: 2/10 checks pass, and with the throwaway prototype applied and the pass fixtures it printed ACCEPTED: 10/10 checks pass. Files the script mutates were left unchanged after each run.
accept_2727.py
"""Acceptance check for p2pool-starter-stack/pithead#2727.
Save this file OUTSIDE the repo (for example /tmp/accept_2727.py) so it is never committed.
Run from the repo root on the PR head, on Linux as CI does, NOT on a bench host:
python3 /tmp/accept_2727.py --results DIR
DIR holds one downloaded tier4-kvm job on the PR head whose phases include stack: DIR/evidence.txt
(the output of `bench-ci evidence <id>@<sha>`) and DIR/run.log (the job's run log as bench-ci
prints it, timestamps included). Without --results the bench checks print FAIL "bench evidence not
supplied". Prints PASS/FAIL per check and exits 0 only when every check passes.
No tracked file is modified. C2-C5 run tests/os/run.sh's own text through bash with three exact
lines swapped: the scratch disk and serial paths point into a temporary directory, and
`require_host` + `require_clean_bench` become "start a lingering child, print a verdict, exit 0".
So every module run.sh sources is loaded and its real EXIT handler tears down, against a fake
`virsh` first on PATH. A fake qemu process for the test VM runs beside it.
"""
import argparse
import json
import os
import re
import signal
import subprocess
import sys
import tempfile
import time
from pathlib import Path
ALLOWED = ("tests/os/", "tests/stack/", "docs/dev/", "CHANGELOG.md")
VM = "pithead-os-test"
LINGER = "accept2727-linger-child"
QEMU = "accept2727-qemu"
SWAPS = [
('DISK="/srv/code/bench-vm/pithead-os-test.img"\n', 'DISK="$ACCEPT_T/disk.img"\n'),
('SERIAL="/tmp/pithead-os-serial.log"\n', 'SERIAL="$ACCEPT_T/serial.log"\n'),
("require_host\nrequire_clean_bench\n",
'SSH_ERR="$ACCEPT_T/ssh.err"\n'
f"if [ -n \"${{ACCEPT_LINGER:-}}\" ]; then bash -c 'exec -a {LINGER} sleep 3600' & fi\n"
"printf '\\nos harness: 0 passed, 0 failed\\n'\nexit 0\n"),
]
FAKE_VIRSH = f"""#!/bin/sh
# destroy/undefine hang in hang mode, as a qemu stuck destroying would; the domain stays listed.
case "$1" in
destroy | undefine) [ "$ACCEPT_VIRSH" = hang ] && exec sleep 86400; exit 0 ;;
list) [ "$ACCEPT_VIRSH" = hang ] && echo {VM}; exit 0 ;;
domstate) echo running ;;
esac
exit 0
"""
DURATION = r"(?<![\w.])\d+(?:\.\d+)?\s*(?:ms|s|sec|secs|seconds)\b"
TIMED = {c: re.compile(rf"virsh {c}\b.*{DURATION}") for c in ("destroy", "undefine")}
ANSI = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")
STAMP = re.compile(r"^(?:\[\w+\]\s*)?(?:(\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?Z\s?)?(?:\[\w+\]\s*)?")
BENCH = ("B1 a tier4-kvm job on the PR head (evidence.txt names HEAD) with stack in its phases completed, "
"and its conclusion is success or failure, not timed_out",
"B2 run.log: the stack phase ran, and after the 'os harness:' verdict the teardown timed "
"virsh destroy and virsh undefine",
"B3 run.log: the virsh undefine timing line is stamped within 300 s of the 'os harness:' verdict")
results = []
def report(name, ok, detail=""):
results.append(ok)
print(f"{'PASS' if ok else 'FAIL'} {name}" + (f" [{detail}]" if detail else ""), flush=True)
def git(*args):
return subprocess.run(["git", *args], capture_output=True, text=True).stdout
def teardown(mode, limit):
"""Run run.sh's text to its EXIT handler. -> (exit code or None if still running at limit, secs, output)."""
text = Path("tests/os/run.sh").read_text()
for old, new in SWAPS:
if text.count(old) != 1:
return None, 0, f"error(anchor found {text.count(old)}x in tests/os/run.sh: {old.strip()[:40]})"
text = text.replace(old, new)
with tempfile.TemporaryDirectory() as t:
bin_dir = Path(t, "bin")
bin_dir.mkdir()
Path(bin_dir, "virsh").write_text(FAKE_VIRSH)
Path(bin_dir, "virsh").chmod(0o755)
env = {**os.environ, "PATH": f"{bin_dir}:{os.environ['PATH']}", "ACCEPT_T": t, "ACCEPT_VIRSH": mode}
qemu = None
if mode == "hang":
env["ACCEPT_LINGER"] = "1"
Path(t, "qemu-system-x86_64").write_text("#!/bin/sh\nwhile :; do sleep 1; done\n")
Path(t, "qemu-system-x86_64").chmod(0o755)
qemu = subprocess.Popen([str(Path(t, "qemu-system-x86_64")), "-name", f"guest={VM},debug-threads=on",
"-uuid", QEMU], start_new_session=True)
out_path = Path(t, "out")
with open(out_path, "w") as out:
start = time.time()
p = subprocess.Popen(["bash", "-c", text, "tests/os/run.sh"], stdout=out, stderr=subprocess.STDOUT,
env=env, start_new_session=True)
try:
code = p.wait(timeout=limit)
except subprocess.TimeoutExpired:
code = None
secs = time.time() - start
for proc in (p, qemu):
if proc is not None:
try:
os.killpg(proc.pid, signal.SIGKILL)
except (ProcessLookupError, PermissionError):
pass
if qemu is not None:
qemu.wait()
return code, secs, ANSI.sub("", out_path.read_text(errors="replace"))
def timed(output):
return {c: any(rx.search(l) for l in output.splitlines()) for c, rx in TIMED.items()}
def evidence(d):
p = d / "evidence.txt"
if not p.is_file():
return None
t = p.read_text()
m = re.search(r"bench-ci job (\d+)@([0-9a-f]{40})\**\s*·\s*\S+\s*·\s*(tier4-[\w-]+)", t)
s = re.search(r"^- status:\s*(\w+)\s*·\s*conclusion:\s*(\w+)\s*·\s*exit\s*(-?\d+)", t, re.M)
o = re.search(r"^- options:\s*(\{.*\})\s*$", t, re.M)
if not (m and s):
return None
try:
phases = json.loads(o[1]).get("phases", []) if o else []
except ValueError:
phases = []
if isinstance(phases, str):
phases = phases.split(",")
return {"job": m[1], "commit": m[2], "tier": m[3], "phases": phases, "status": s[1], "conclusion": s[2]}
def stamped(path):
"""-> [(seconds of day or None, text)] with ANSI codes and bench-ci's stamp removed."""
out = []
for raw in path.read_text(errors="replace").splitlines():
line = ANSI.sub("", raw)
m = STAMP.match(line)
secs = int(m[1]) * 3600 + int(m[2]) * 60 + int(m[3]) if m and m[1] else None
out.append((secs, line[m.end():] if m else line))
return out
parser = argparse.ArgumentParser()
parser.add_argument("--results", type=Path)
args = parser.parse_args()
subprocess.run(["git", "fetch", "-q", "origin", "develop"], check=False)
base = git("merge-base", "origin/develop", "HEAD").strip()
head = git("rev-parse", "HEAD").strip()
changed = set(git("diff", "--name-only", base).split())
outside = sorted(f for f in changed if not f.startswith(ALLOWED))
report("C1 changes stay in tests/os/, tests/stack/ and docs/dev/ (CHANGELOG.md allowed) and touch tests/os/",
not outside and any(f.startswith("tests/os/") for f in changed), f"changed: {sorted(changed)}")
code, secs, out = teardown("hang", 300)
err = out if out.startswith("error(") else ""
report("C2 with virsh destroy and virsh undefine both hung, run.sh's teardown ends within 300 s",
not err and code is not None,
err or (f"exit {code} after {secs:.0f} s" if code is not None else f"still running after {secs:.0f} s, killed"))
t = timed(out)
report("C3 that hung teardown prints how long virsh destroy and virsh undefine each took",
not err and all(t.values()), err or f"timed: {t}")
names = {"lingering child of run.sh": LINGER in out, "qemu process for the test VM": QEMU in out}
report("C4 that hung teardown names what was still running: a lingering child of run.sh and the VM's qemu",
not err and all(names.values()), err or f"named: {names}")
code, secs, out = teardown("ok", 60)
err = out if out.startswith("error(") else ""
t = timed(out)
report("C5 a healthy teardown still exits 0 within 60 s and times both virsh calls",
not err and code == 0 and all(t.values()), err or f"exit {code} after {secs:.0f} s, timed: {t}")
r = subprocess.run(["bash", "tests/os/kvm-preflight.sh"], capture_output=True, text=True,
env={**os.environ, "PITHEAD_OS_VM_DESTROY_SELF_TEST": "1"})
report("C6 the vm_destroy self-test passes (PITHEAD_OS_VM_DESTROY_SELF_TEST=1 bash tests/os/kvm-preflight.sh)",
r.returncode == 0, f"exit {r.returncode}")
r = subprocess.run(["bash", "tests/os/selftest-run-modules.sh"], capture_output=True, text=True)
report("C7 tests/os/selftest-run-modules.sh passes (core.sh's function list is pinned there)",
r.returncode == 0 and "os-run-modules: PASS" in r.stdout + r.stderr, f"exit {r.returncode}")
if args.results is None:
for name in BENCH:
report(name, False, "bench evidence not supplied")
else:
ev = evidence(args.results)
report(BENCH[0], bool(ev) and ev["commit"] == head and ev["tier"] == "tier4-kvm" and ev["status"] == "completed"
and bool({"stack", "all"} & set(ev["phases"])) and ev["conclusion"] in ("success", "failure"),
f"{args.results}/evidence.txt missing or unparsable" if not ev else
f"job {ev['job']}, commit {ev['commit'][:12]}, phases {ev['phases']}, status {ev['status']}, "
f"conclusion {ev['conclusion']}")
log = args.results / "run.log"
lines = stamped(log) if log.is_file() else []
texts = [x for _, x in lines]
v = next((i for i, x in enumerate(texts) if x.startswith("os harness:")), None)
stack_ran = any(x.startswith("==> phase: stack") for x in texts[:v])
after = {c: next((i for i in range(v + 1, len(texts)) if rx.search(texts[i])), None)
for c, rx in TIMED.items()} if v is not None else {}
report(BENCH[1], v is not None and stack_ran and all(i is not None for i in after.values()),
f"verdict line {'found' if v is not None else 'missing'}, stack phase ran: {stack_ran}, "
f"timing lines after the verdict: {sorted(c for c, i in after.items() if i is not None)}")
if v is None or after.get("undefine") is None or lines[v][0] is None or lines[after["undefine"]][0] is None:
report(BENCH[2], False, "verdict line, undefine timing line or their timestamps missing")
else:
gap = (lines[after["undefine"]][0] - lines[v][0]) % 86400
report(BENCH[2], gap <= 300, f"{gap} s after the verdict")
print(f"\n{'ACCEPTED' if all(results) else 'NOT ACCEPTED'}: {sum(results)}/{len(results)} checks pass")
sys.exit(0 if all(results) else 1)possible solutions
No distinct solution options are recorded; investigate the existing report before choosing an approach.
Activity
fix(os): let a function-stubbed virsh run the bounded teardown (#2727)
pithead-developer commentedon Oct 12, 2026
Review returned: the operator's call (rule here, then remove the
review-returnedlabel):Review of PR #2728 did not pass after round 2 (RETURN).
Teardown exceeds the accepted 300-second bound, can hang when SIGTERM is ignored, and does not identify a hung list call. Current-head KVM evidence and the issue’s acceptance output are missing. The review is published on PR #2728; the runner must post the commit status.
pithead-architect commentedon Oct 12, 2026
Ruling: The four returns stand; the PR goes back to the worker for round 3, same branch, no fork. Fix in
tests/os/kvm-preflight.sh: (1) one timed wrapper for every teardown call, destroy, undefine and list alike,timeout -k 10 60 virsh …by default, so the worst case with all three hung is 3 × 70 s = 210 s, inside the issue's 300 s ceiling; keepPITHEAD_VM_TEARDOWN_TIMEOUTas the per-call bound and state the 3 × (bound + 10) total in the README. (2) The wrapper logs the duration and rc for every call, treats rc 124 (cut) and 137 (TERM ignored, killed) both as hung, and prints the qemu and child diagnostics on either; list's stdout stays captured into the variable the caller reads while its timing goes to the log, so a list-only hang namesvirsh list. (3) Extend the self-test with the three cases the reviewer probed, both calls hung, a TERM-ignoring stub, and a list-only hang, each with a short bound so the tooling test stays quick, each shown to fail on the previous head and pass on this one. (4) Evidence: run the issue's unchanged acceptance script on a Linux host (your hosted session box, not the bench) at the final head and paste its complete output into the PR body; that run is the default-settings proof of C2 to C5. Then one tier4-kvm job,phases=stack, on the final head: quote the verdict line, the three timing lines and the exit, and record thebench-ci evidence ID@SHAreference instead of a log URL, since logs expire. (5) Rewrite the Evidence section in place: job 1224 and anything cited from a prior head come out, no 'queued' lines, no expired links. Returnwaitingwith the job inbench_jobsuntil it concludes, and only then post Ready for review. Root cause of the 13-minute hang (ask 2) and the 207/220 budget (ask 3) stay out of this PR as the body already says.pithead-developer commentedon Oct 19, 2026
Filed privately (pithead-2727.md); it needs an answer there, then remove the
questionlabel.fix(os): bound and report every KVM teardown call (#2727)
pithead-developer commentedon Oct 19, 2026
Waiting on a transient bench_outage condition, not on another issue. tier4-kvm submission and same-idempotency-key retry failed with urlopen error [Errno 65] No route to host; no job ID returned. The runner re-checks it (first at 2026-10-19T13:55Z, at most 5 times).
13 remaining items
pithead-developer commentedon Oct 27, 2026
Filed privately (pithead-2727.md); it needs an answer there, then remove the
questionlabel.pithead-developer commentedon Oct 27, 2026
Grouped with #2511, but PR #3504 does not close it: Independent KVM teardown work already has PR #2728 and requires separate tier4-kvm stack proof.. Released for its own pick.
pithead-developer commentedon Oct 30, 2026
Blocked on #3786. PR #2728 records completed KVM job 3200: teardown satisfies B1–B3, while the overall job failed in separately owned rows. Required CI is blocked by #3786 and #3795; their owners must land fixes before refreshing the candidate and repeating exact-head proof, including the unrun Ubuntu acceptance and negative control.
The runner guard refused temporary tooling-branch deletion; operator cleanup remains.
The runner resumes this issue when that one closes.
pithead-developer commentedon Oct 31, 2026
Needs an operator action (do it, then close this or, then remove the
operator-actionlabel):PR #2728 has green CI, 10/10 Ubuntu acceptance and clean reviews; KVM job 3220 remains failed in unrelated rows owned by #3625 and #3794. Before merge, the owner/operator must delete temporary branch agent/2727-ubuntu-acceptance-004958bc, as required by the reviewer brief.
The worker pre-push guard refused remote branch deletion from a runner checkout.
pithead-developer commentedon Nov 1, 2026
Operator: deleted the temporary acceptance branch, 6308a23 -> absent head, verified; PR #2728 remains an open draft at 6c73626.
pithead-developer commentedon Nov 2, 2026
Merged in #2728.
fix(os): bound and time the KVM guest teardown (#2727) (#2728)