Skip to content

Commit

Permalink
Fix use case where Volume has no mount point either
Browse files Browse the repository at this point in the history
  • Loading branch information
olethanh committed Jan 6, 2025
1 parent bbfcda6 commit 175f49b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/aleph/vm/controllers/firecracker/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ async def download_kernel(self):
async def download_volumes(self):
volumes = []
# TODO: Download in parallel
for volume in self.message_content.volumes:
for i, volume in enumerate(self.message_content.volumes):
if not volume.name:
volume.name = f"unamed_volume_{i}"
if not volume.mount:
volume.mount = f"/mnt/{volume.name}"
volumes.append(
HostVolume(
mount=volume.mount,
Expand Down
2 changes: 0 additions & 2 deletions src/aleph/vm/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ async def get_volume_path(volume: MachineVolume, namespace: str) -> Path:
return await get_existing_file(ref)
elif isinstance(volume, PersistentVolume | RootfsVolume):
volume_name = volume.name if isinstance(volume, PersistentVolume) else "rootfs"
if not volume.name:
volume_name = f"unamed_{uuid.uuid4().hex}"
if volume.persistence != VolumePersistence.host:
msg = "Only 'host' persistence is supported"
raise NotImplementedError(msg)
Expand Down
10 changes: 9 additions & 1 deletion tests/supervisor/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,15 @@ async def test_create_execution_volume_with_no_name(fake_message):
"name": "",
"size_mib": 1,
}
fake_message["content"]["volumes"] = [volume_with_no_name]
volume_with_no_mount = {
"comment": "Persistence with no mount name",
"mount": "",
"parent": None,
"persistence": "host",
"name": "",
"size_mib": 1,
}
fake_message["content"]["volumes"] = [volume_with_no_name, volume_with_no_mount]
fake_message = drop_none_recursively(fake_message)
fix_message_validation(fake_message)

Expand Down

0 comments on commit 175f49b

Please sign in to comment.