fix(firecracker): abort cleanup on scan errors
tracker-policy-pr / check-pr (pull_request) Failing after 14s
lint / lint (push) Successful in 1m11s
test / image-input-builds (pull_request) Successful in 1m3s
test / integration-docker (pull_request) Successful in 1m6s
test / unit (pull_request) Failing after 11m55s
prd-number-check / require-numbered-prds (pull_request) Failing after 11m57s
test / coverage (pull_request) Has been skipped

This commit is contained in:
2026-07-26 22:43:02 +00:00
parent 38d3f0fe0c
commit 9fd769ab79
2 changed files with 46 additions and 6 deletions
+17 -5
View File
@@ -29,6 +29,7 @@ import subprocess
from pathlib import Path
from ...log import info
from .. import EnumerationError
from . import util
from .bottle_cleanup_plan import FirecrackerBottleCleanupPlan
@@ -62,12 +63,23 @@ def _scan_processes(run_root: Path) -> tuple[set[str], list[int]]:
* ``orphan_pids`` — firecracker pids whose run dir no longer exists
(a lingering VMM to kill).
"""
result = subprocess.run(
["pgrep", "-a", "firecracker"],
capture_output=True, text=True, check=False,
)
if result.returncode != 0:
try:
result = subprocess.run(
["pgrep", "-a", "firecracker"],
capture_output=True, text=True, check=False,
)
except OSError as exc:
raise EnumerationError(
f"could not enumerate Firecracker processes: {exc}"
) from exc
if result.returncode == 1:
# pgrep's documented "no processes matched" result.
return set(), []
if result.returncode != 0:
detail = (result.stderr or "").strip() or f"exit {result.returncode}"
raise EnumerationError(
f"could not enumerate Firecracker processes: {detail}"
)
live: set[str] = set()
orphan_pids: list[int] = []
for line in result.stdout.splitlines():