Skip to content

Commit 9bfe98a

Browse files
pb8ozulinx86
authored andcommitted
fix(tests): prevent race conditions in firecracker_release fixture
There are some new errors[1]: FileExistsError: [Errno 17] File exists: (from /firecracker/tests/integration_tests/functional/conftest.py) We removed some locks when simplifying the build. This function was depending on get_binary to serialize accesses, but it was always vulnerable to race conditions to begin with. [1]: https://buildkite.com/firecracker/firecracker-pr/builds/9536#018e65dd-d001-4c41-afc0-6a4ef97d2790/58-586 Fixes: df112e3 Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent e185ed1 commit 9bfe98a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/framework/artifacts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from framework.defs import ARTIFACT_DIR
1515
from framework.properties import global_props
1616
from framework.utils import get_firecracker_version_from_toml, run_cmd
17+
from framework.with_filelock import with_filelock
1718
from host_tools.cargo_build import get_binary
1819

1920

@@ -131,6 +132,7 @@ def snapshot_version(self):
131132
return ".".join(str(x) for x in self.snapshot_version_tuple)
132133

133134

135+
@with_filelock
134136
def current_release(version):
135137
"""Massage this working copy Firecracker binary to look like a normal
136138
release, so it can run the same tests.
@@ -139,8 +141,9 @@ def current_release(version):
139141
for binary in ["firecracker", "jailer"]:
140142
bin_path1 = get_binary(binary)
141143
bin_path2 = bin_path1.with_name(f"{binary}-v{version}")
142-
bin_path2.unlink(missing_ok=True)
143-
bin_path2.hardlink_to(bin_path1)
144+
if not bin_path2.exists():
145+
bin_path2.unlink(missing_ok=True)
146+
bin_path2.hardlink_to(bin_path1)
144147
binaries.append(bin_path2)
145148
return binaries
146149

0 commit comments

Comments
 (0)