Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Keep failed backend task groups owned through cleanup

pulse-triage[bot]471c891ad136
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 65658f9997..9608964e60 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -5015,6 +5015,8 @@ gets a separate data directory, and any failed child fails the gate and cleans
up its siblings. Each task has its own process group: failure signals every
group before waiting, with bounded TERM-to-KILL escalation, rather than racing
a recursive process-tree snapshot against child creation.
+The failed task's own group remains in that cleanup set even after its leader
+exits, so a surviving descendant cannot disappear with the released PID.
Already completed children are joined by their retained PID, because Bash
`wait -n` can otherwise omit their saved exit status. A no-job race triggers
reconciliation of the same PIDs, never a task replay or an assumed pass.
diff --git a/scripts/installtests/build_release_assets_test.go b/scripts/installtests/build_release_assets_test.go
index e8f77b5bfc..4335523b58 100644
--- a/scripts/installtests/build_release_assets_test.go
+++ b/scripts/installtests/build_release_assets_test.go
@@ -4878,6 +4878,11 @@ func TestReleaseBackendRaceGateUsesCompleteWorkerPartition(t *testing.T) {
t.Fatalf("release backend partition missing coverage contract: %s", needle)
}
}
+ failedTaskExit := strings.Index(backendScript, `if [ "$status" -ne 0 ]; then exit "$status"; fi`)
+ leaseRelease := strings.Index(backendScript, `free_procs=$((free_procs + task_widths[$completed_pid]))`)
+ if failedTaskExit < 0 || leaseRelease < failedTaskExit {
+ t.Fatal("failed task process groups must remain owned until failure cleanup")
+ }
}
func TestHelmAgentRuntimePointsAtRealImage(t *testing.T) {
diff --git a/scripts/run-release-backend-tests.sh b/scripts/run-release-backend-tests.sh
index cf1bd67bbe..9421ad15fa 100755
--- a/scripts/run-release-backend-tests.sh
+++ b/scripts/run-release-backend-tests.sh
@@ -407,6 +407,9 @@ while [ "$next_package" -lt "${#OTHER_PACKAGES[@]}" ] || [ "${#pids[@]}" -gt 0 ]
fi
printf 'finish\t%s\t%s\t%s\t%s\t%s\n' "$completed_pid" "${task_widths[$completed_pid]}" \
"$((SECONDS - task_starts[$completed_pid]))" "$status" "${task_names[$completed_pid]}" >> "$RUN_ROOT/coverage/execution.tsv"
+ # Keep the failed task's group in cleanup too: its leader may have exited
+ # while an owned descendant is still running in that same group.
+ if [ "$status" -ne 0 ]; then exit "$status"; fi
free_procs=$((free_procs + task_widths[$completed_pid]))
active=()
for pid in "${pids[@]}"; do
@@ -414,7 +417,6 @@ while [ "$next_package" -lt "${#OTHER_PACKAGES[@]}" ] || [ "${#pids[@]}" -gt 0 ]
done
pids=("${active[@]}")
unset 'task_widths[$completed_pid]' 'task_names[$completed_pid]' 'task_starts[$completed_pid]'
- if [ "$status" -ne 0 ]; then exit "$status"; fi
done
echo "Race-enabled backend release tests passed with $API_SHARDS API shard(s)."
diff --git a/scripts/tests/test_release_backend_queue.py b/scripts/tests/test_release_backend_queue.py
index 0c97c6aef9..594212852c 100644
--- a/scripts/tests/test_release_backend_queue.py
+++ b/scripts/tests/test_release_backend_queue.py
@@ -8,6 +8,7 @@ from pathlib import Path
import re
import shutil
import subprocess
+import sys
import tempfile
import unittest
@@ -65,6 +66,7 @@ def record(event):
with (root / "children.jsonl").open("a") as f:
fcntl.flock(f, fcntl.LOCK_EX)
f.write(json.dumps(dict(event=event, name=name, pid=os.getpid(),
+ pgid=os.getpgrp(),
width=int(os.environ["GOMAXPROCS"]), selected=selected,
data=os.environ["PULSE_DATA_DIR"], ignores_term=ignores_term,
time=time.monotonic())) + "\n")
@@ -83,12 +85,22 @@ if os.environ["QUEUE_CPUS"] == "4":
sys.exit(97)
time.sleep(.01)
time.sleep(delay)
+if os.environ.get("QUEUE_ORPHAN") and name.endswith("internal/monitoring"):
+ ready = root / "orphan-ready"
+ if os.fork() == 0:
+ ignores_term = True
+ signal.signal(signal.SIGTERM, signal.SIG_IGN)
+ record("orphan-start"); ready.touch()
+ time.sleep(10)
+ record("orphan-finish"); os._exit(0)
+ while not ready.exists(): time.sleep(.01)
record("finish")
if os.environ.get("QUEUE_FAIL") in (name, "api" if selected else "other"):
sys.exit(19)
'''
[email protected](sys.platform == "linux", "release backend runner uses Linux Bash job control")
class ReleaseBackendQueueTest(unittest.TestCase):
def run_queue(self, cpus=4, packages=None, **extra):
with tempfile.TemporaryDirectory() as directory:
@@ -123,10 +135,23 @@ class ReleaseBackendQueueTest(unittest.TestCase):
coverage = root / "data/release-backend-run/coverage"
receipts = list(csv.DictReader((coverage / "execution.tsv").read_text().splitlines(), delimiter="\t")) if (coverage / "execution.tsv").exists() else []
selected = (coverage / "non-api-packages.txt").read_text().splitlines() if (coverage / "non-api-packages.txt").exists() else []
+ groups = {int(row["pid"]) for row in receipts if row["event"] == "start"}
for event in events:
- if event["event"] == "start":
- with self.assertRaises(ProcessLookupError, msg="runner left a child alive"):
+ if event["event"] in ("start", "orphan-start"):
+ self.assertIn(event["pgid"], groups, "child escaped its owned task process group")
+ try:
os.kill(event["pid"], 0)
+ except ProcessLookupError:
+ continue
+ try:
+ state = Path(f"/proc/{event['pid']}/stat").read_text().rsplit(")", 1)[1].split()[0]
+ except (FileNotFoundError, ProcessLookupError):
+ continue
+ # A just-killed orphan may await init's reap. Z is a dead,
+ # non-executing process, not a live child or command pass.
+ if state == "Z":
+ continue
+ self.fail(f"runner left child {event['pid']} {event['name']} in state {state}")
return result, events, receipts, selected
def test_complete_source_inventory_reuses_finished_api_width(self):
@@ -211,6 +236,13 @@ test "$completed_pid" = "${{pids[0]}}" && test "$status" = {child_exit}
text=True, timeout=5)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
+ def test_cleanup_includes_descendants_of_the_failed_task(self):
+ result, events, _, _ = self.run_queue(
+ QUEUE_FAIL=MODULE + "internal/monitoring", QUEUE_ORPHAN="1")
+ self.assertEqual(result.returncode, 19, result.stdout + result.stderr)
+ self.assertEqual([e["event"] for e in events if e["event"].startswith("orphan")],
+ ["orphan-start"])
+
if __name__ == "__main__":
unittest.main()