Skip to content

fix(test): retry reading pid file a few times #5324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions tests/framework/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pathlib import Path
from typing import Optional

from tenacity import retry, stop_after_attempt, wait_fixed
from tenacity import Retrying, retry, stop_after_attempt, wait_fixed

import host_tools.cargo_build as build_tools
import host_tools.network as net_tools
Expand Down Expand Up @@ -481,8 +481,16 @@ def firecracker_pid(self):
"""
if not self._spawned:
return None
# Read the PID stored inside the file.
return int(self.jailer.pid_file.read_text(encoding="ascii"))

# Read the PID from Firecracker's pidfile. Retry if
# file doesn't exist yet, or doesn't yet contain an integer
for attempt in Retrying(
stop=stop_after_attempt(5),
wait=wait_fixed(0.1),
reraise=True,
):
with attempt:
return int(self.jailer.pid_file.read_text(encoding="ascii"))

@property
def dimensions(self):
Expand Down