Skip to content

Commit

Permalink
Availability: Skip bad configurations
Browse files Browse the repository at this point in the history
Mismatches in Availability Set requirements and capabilities may be due to test case requirements, so we can skip the test instead of failing.
  • Loading branch information
kamalca committed Nov 11, 2024
1 parent b3e1f46 commit 86eca00
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions lisa/sut_orchestrator/azure/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,7 @@ def create_setting(
return availability_settings

@classmethod
def on_before_deployment(cls, *args: Any, **kwargs: Any) -> None:
def on_before_deployment(cls, *args: Any, **kwargs: Any) -> None: # noqa: C901
environment = cast(Environment, kwargs.get("environment"))
arm_parameters = cast(AzureArmParameter, kwargs.get("arm_parameters"))
settings = cast(AvailabilitySettings, kwargs.get("settings"))
Expand Down Expand Up @@ -2477,27 +2477,29 @@ def on_before_deployment(cls, *args: Any, **kwargs: Any) -> None:
for zone in params.availability_zones
if zone in settings.availability_zones
]
assert params.availability_zones, (
"Invalid zones provided. "
"This SKU in this location supports zones: "
f"{settings.availability_zones}. "
)
if not params.availability_zones:
raise SkippedException(
"Invalid zones provided. "
"This SKU in this location supports zones: "
f"{settings.availability_zones}. "
)
elif settings.availability_zones:
params.availability_zones = [settings.availability_zones.items[0]]

assert params.availability_type in [
type.value for type in AvailabilityType
], ("Not a valid Availability Type: " f"{params.availability_type}")

assert (
if not (
AvailabilityType(params.availability_type) in settings.availability_type
), (
f"Availability Type "
f"'{params.availability_type}' "
"is not supported in the current configuration. Please select one of "
f"{[type.value for type in settings.availability_type.items]}. "
"Or consider changing the disk type or location."
)
):
raise SkippedException(
f"Availability Type "
f"'{params.availability_type}' "
"is not supported in the current configuration. Please select one of "
f"{[type.value for type in settings.availability_type.items]}. "
"Or consider changing the disk type or location."
)

# If the availability_type is still set to Default, then
# resolve the default without considering capabilities
Expand All @@ -2517,9 +2519,14 @@ def on_before_deployment(cls, *args: Any, **kwargs: Any) -> None:
if "platformUpdateDomainCount" not in params.availability_set_properties:
params.availability_set_properties["platformUpdateDomainCount"] = 1
elif params.availability_type == AvailabilityType.AvailabilityZone:
assert (
params.availability_zones
), "Availability Zone is selected, but no zone was provided."
if not params.availability_zones:
raise SkippedException(
"Availability Zone is selected, but no zone was provided. "
"Please consider one of the following\n"
"1. Providing availability_zones in the runbook\n"
"2. Selecting a different availability_type in the runbook\n"
"3. Setting maximize_capability to false so the zone can be selected automatically."
)
params.availability_zones = [params.availability_zones[0]]
params.availability_set_tags.clear()
params.availability_set_properties.clear()
Expand Down

0 comments on commit 86eca00

Please sign in to comment.