Skip to content

Commit

Permalink
vm resize: filter vm size with proper disk properties
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Nov 14, 2024
1 parent 4ec8c8d commit 88f6f40
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lisa/sut_orchestrator/azure/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,29 @@ def resize(
self._node.capability = cast(schema.Capability, new_capability)
return new_capability, origin_vm_size, new_vm_size_info.vm_size

def _compare_disk_property(
self,
candidate_size: AzureCapability,
current_vm_size: AzureCapability,
property_name: str,
) -> bool:
assert candidate_size.capability
assert current_vm_size.capability
assert candidate_size.capability.disk
assert current_vm_size.capability.disk
candidate_value = getattr(candidate_size.capability.disk, property_name, None)
current_value = getattr(current_vm_size.capability.disk, property_name, None)

if candidate_value is None or current_value is None:
return False

# If both values are iterable (list or set), check if there's any match
if isinstance(candidate_value, (list, set)):
return any(dc_type in candidate_value for dc_type in current_value)

# Otherwise, do a simple direct comparison
return candidate_value == current_value

def _select_vm_size(
self, resize_action: ResizeAction = ResizeAction.IncreaseCoreCount
) -> Tuple[str, "AzureCapability"]:
Expand Down Expand Up @@ -2098,6 +2121,22 @@ def _select_vm_size(
avail_eligible_intersect.remove(candidate_size)
continue

disk_properties_to_compare = [
"disk_controller_type",
"os_disk_type",
"data_disk_type"
]
candidate_passed_all_checks = True
for prop in disk_properties_to_compare:
if not self._compare_disk_property(
candidate_size, current_vm_size, prop
):
candidate_passed_all_checks = False
break
if not candidate_passed_all_checks:
avail_eligible_intersect.remove(candidate_size)
continue

candidate_gen = [
feature
for feature in candidate_size.capability.features
Expand Down

0 comments on commit 88f6f40

Please sign in to comment.