Skip to content
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

FirecrackerVM drive not working if /var/lib and /var/cache on two sep… #711

Merged
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
7 changes: 6 additions & 1 deletion src/aleph/vm/hypervisors/firecracker/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
def enable_drive(self, drive_path: Path, read_only: bool = True) -> Drive:
"""Make a volume available to the VM.

Creates a symlink to the volume file if jailer is in use.
Creates a hardlink or a copy to the volume file if jailer is in use.
"""
index = len(self.drives)
device_name = self.compute_device_name(index)
Expand All @@ -376,6 +376,11 @@

try:
Path(f"{self.jailer_path}/{jailer_path_on_host}").hardlink_to(drive_path)
except OSError as err:

Check warning on line 379 in src/aleph/vm/hypervisors/firecracker/microvm.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/hypervisors/firecracker/microvm.py#L379

Added line #L379 was not covered by tests
if err.errno == errno.EXDEV:
# Invalid cross-device link: cannot make hard link between partition.
# In this case, copy the file instead:
shutil.copyfile(drive_path, f"{self.jailer_path}/{jailer_path_on_host}")

Check warning on line 383 in src/aleph/vm/hypervisors/firecracker/microvm.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/hypervisors/firecracker/microvm.py#L383

Added line #L383 was not covered by tests
except FileExistsError:
logger.debug(f"File {jailer_path_on_host} already exists")
drive_path = Path(jailer_path_on_host)
Expand Down