Skip to content

Commit 9bb3a21

Browse files
committed
test: ignore spurious exception during jailer cleanup
A race-condition during test execution sometimes caused the destructor of some jailer instance to be called twice. This causes spurious test failures. In this commit, we ignore that exception, with a note that long-term we should not rely on destructors to do resource managements for us. Signed-off-by: Patrick Roy <[email protected]>
1 parent 96d4064 commit 9bb3a21

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/framework/jailer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@ def cleanup(self):
256256
shutil.rmtree(self.chroot_base_with_id(), ignore_errors=True)
257257

258258
if self.netns and os.path.exists("/var/run/netns/{}".format(self.netns)):
259-
utils.run_cmd("ip netns del {}".format(self.netns))
259+
try:
260+
utils.run_cmd("ip netns del {}".format(self.netns))
261+
except ChildProcessError:
262+
# Sometimes, a race condition in pytest causes this destructor to run twice.
263+
# Long-term, we'll want to do cleanup properly, but for now we ignore
264+
# the exception
265+
pass
260266

261267
# Remove the cgroup folders associated with this microvm.
262268
# The base /sys/fs/cgroup/<controller>/firecracker folder will remain,

0 commit comments

Comments
 (0)