Skip to content

Commit

Permalink
Add EphemeralDiskPlacementType to DiskOptionSettings in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
sharsonia committed Dec 13, 2024
1 parent 6348227 commit 8887cac
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
53 changes: 53 additions & 0 deletions lisa/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,22 @@ class ResourceDiskType(str, Enum):
NVME = constants.STORAGE_INTERFACE_TYPE_NVME


class EphemeralDiskPlacementType(str, Enum):
Resource = constants.DISK_PLACEMENT_TYPE_RESOURCE
Cache = constants.DISK_PLACEMENT_TYPE_CACHE
Nvme = constants.DISK_PLACEMENT_TYPE_NVME


disk_controller_type_priority: List[DiskControllerType] = [
DiskControllerType.SCSI,
DiskControllerType.NVME,
]

ephemeral_disk_placement_type_priority: List[EphemeralDiskPlacementType] = [
EphemeralDiskPlacementType.Nvme,
EphemeralDiskPlacementType.Cache,
EphemeralDiskPlacementType.Resource,
]

os_disk_types: List[DiskType] = [
DiskType.StandardHDDLRS,
Expand Down Expand Up @@ -559,6 +570,34 @@ class DiskOptionSettings(FeatureSettings):
)
),
)
ephemeral_disk_placement_type: Optional[
Union[
search_space.SetSpace[
EphemeralDiskPlacementType
],
EphemeralDiskPlacementType,
]
] = field( # type:ignore
default_factory=partial(
search_space.SetSpace,
items=[
EphemeralDiskPlacementType.Resource,
EphemeralDiskPlacementType.Cache,
EphemeralDiskPlacementType.Nvme,
],
),
metadata=field_metadata(
decoder=partial(
search_space.decode_nullable_set_space,
base_type=EphemeralDiskPlacementType,
default_values=[
EphemeralDiskPlacementType.Resource,
EphemeralDiskPlacementType.Cache,
EphemeralDiskPlacementType.Nvme,
],
)
),
)

def __eq__(self, o: object) -> bool:
if not super().__eq__(o):
Expand All @@ -577,6 +616,7 @@ def __eq__(self, o: object) -> bool:
and self.data_disk_size == o.data_disk_size
and self.max_data_disk_count == o.max_data_disk_count
and self.disk_controller_type == o.disk_controller_type
and self.ephemeral_disk_placement_type == o.ephemeral_disk_placement_type
)

def __repr__(self) -> str:
Expand All @@ -591,6 +631,7 @@ def __repr__(self) -> str:
f"size: {self.data_disk_size},"
f"max_data_disk_count: {self.max_data_disk_count},"
f"disk_controller_type: {self.disk_controller_type}"
f"ephemeral_disk_placement_type: {self.ephemeral_disk_placement_type}"
)

def __str__(self) -> str:
Expand Down Expand Up @@ -641,6 +682,7 @@ def _get_key(self) -> str:
f"{self.data_disk_caching_type}/{self.data_disk_iops}/"
f"{self.data_disk_throughput}/{self.data_disk_size}/"
f"{self.disk_controller_type}"
f"{self.ephemeral_disk_placement_type}"
)

def _call_requirement_method(
Expand Down Expand Up @@ -700,6 +742,17 @@ def _call_requirement_method(
capability.disk_controller_type,
disk_controller_type_priority,
)
if (
self.ephemeral_disk_placement_type
or capability.ephemeral_disk_placement_type
):
value.ephemeral_disk_placement_type = getattr(
search_space, f"{method.value}_setspace_by_priority"
)(
self.ephemeral_disk_placement_type,
capability.ephemeral_disk_placement_type,
ephemeral_disk_placement_type_priority,
)

return value

Expand Down
7 changes: 7 additions & 0 deletions lisa/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,10 @@
# StorageInterfaceTypes
STORAGE_INTERFACE_TYPE_NVME = "NVMe"
STORAGE_INTERFACE_TYPE_SCSI = "SCSI"

# SupportedEphemeralOSDiskPlacements
# refer
# https://learn.microsoft.com/en-us/azure/virtual-machines/ephemeral-os-disks-faq
DISK_PLACEMENT_TYPE_RESOURCE = "ResourceDisk"
DISK_PLACEMENT_TYPE_CACHE = "CacheDisk"
DISK_PLACEMENT_TYPE_NVME = "NvmeDisk"

0 comments on commit 8887cac

Please sign in to comment.