Skip to content

Commit dc21c45

Browse files
committed
refactor(test): add more debugging for "jailer id still used"
Clean up the error messages we print when running into the "firecracker pid was killed, but process with its jailer id still exists" case: Also print the PID of the offending process, as well as filter out non-firecracker processes from the error message (otherwise the error message always contained the grep process itself, which was confusing). Note that `cmd` must be the last column, as otherwise ps will truncate it. Signed-off-by: Patrick Roy <[email protected]>
1 parent a522ef7 commit dc21c45

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/framework/microvm.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,20 @@ def kill(self):
333333
# https://github.com/firecracker-microvm/firecracker/pull/4442/commits/d63eb7a65ffaaae0409d15ed55d99ecbd29bc572
334334

335335
# filter ps results for the jailer's unique id
336-
_, stdout, stderr = utils.check_output(
337-
f"ps ax -o cmd -ww | grep {self.jailer.jailer_id}"
336+
_, stdout, stderr = utils.run_cmd(
337+
f"ps ax -o pid,cmd -ww | grep {self.jailer.jailer_id}"
338338
)
339+
340+
offenders = []
341+
for proc in stdout.splitlines():
342+
if "firecracker" in proc:
343+
offenders.append(proc)
344+
339345
# make sure firecracker was killed
340-
assert (
341-
stderr == "" and "firecracker" not in stdout
342-
), f"Firecracker reported its pid {self.firecracker_pid}, which was killed, but there still exist processes using the supposedly dead Firecracker's jailer_id: {stdout}"
346+
assert not stderr and not offenders, (
347+
f"Firecracker reported its pid {self.firecracker_pid}, which was killed, but there still exist processes using the supposedly dead Firecracker's jailer_id: \n"
348+
+ "\n".join(offenders)
349+
)
343350

344351
if self.uffd_handler and self.uffd_handler.is_running():
345352
self.uffd_handler.kill()

0 commit comments

Comments
 (0)