Skip to content

Commit e6ceb57

Browse files
committed
test: catch correct exception in memory.py
The access to the `firecracker_pid` property causes a read to the vm's pid file. This means that in the scenario where the VM is already dead by the time the monitor starts running, we won't get a `NoSuchProcess` error, we potentially get a `FileNotFoundError` (if the jail is already cleaned up). Thus, to avoid spurious failures, also catch `FileNotFoundError`. We leave the catch for `NoSuchProcess` error in case a VM exits between reading the pid file and the call to the`psutils.Process` constructor (race condition). Signed-off-by: Patrick Roy <[email protected]>
1 parent d6a14fb commit e6ceb57

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/host_tools/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run(self):
6262
guest_mem_bytes = self._vm.mem_size_bytes
6363
try:
6464
ps = psutil.Process(self._vm.firecracker_pid)
65-
except psutil.NoSuchProcess:
65+
except (psutil.NoSuchProcess, FileNotFoundError):
6666
return
6767
while not self._should_stop:
6868
try:

0 commit comments

Comments
 (0)