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

Skylark init caches Azure regions & SKU availability #339

Merged
merged 6 commits into from
May 18, 2022

Conversation

antonzabreyko
Copy link
Contributor

No description provided.

@antonzabreyko antonzabreyko requested a review from parasj May 12, 2022 03:19
Copy link
Contributor

@parasj parasj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment on lines 92 to 101

@staticmethod
def lookup_valid_instance(region: str, instance_name: str) -> Optional[str]:
# todo this should query the Azure API for available SKUs
available_regions = {
"Standard_D32_v5": [
"australiaeast",
"canadacentral",
"eastus",
"eastus2",
"francecentral",
"germanywestcentral",
"japaneast",
"koreacentral",
"northcentralus",
"northeurope",
"uksouth",
"westeurope",
"westus",
"westus2",
"westus3",
],
"Standard_D32_v4": [
"australiaeast",
"brazilsouth",
"canadacentral",
"centralindia",
"eastasia",
"eastus",
"francecentral",
"germanywestcentral",
"japaneast",
"koreacentral",
"northcentralus",
"northeurope",
"norwayeast",
"southafricanorth",
"swedencentral",
"switzerlandnorth",
"uaenorth",
"uksouth",
"westeurope",
"westus",
"westus3",
],
}
if region in available_regions["Standard_D32_v5"] and instance_name == "Standard_D32_v5":
sku_mapping = AzureAuthentication.get_sku_mapping()
if instance_name == "Standard_D32_v5" and "Standard_D32_v5" in sku_mapping[region]:
return "Standard_D32_v5"
elif region in available_regions["Standard_D32_v4"] and instance_name == "Standard_D32_v5":
elif instance_name == "Standard_D32_v4" and "Standard_D32_v4" in sku_mapping[region]:
return "Standard_D32_v4"
else:
logger.error(f"Cannot confirm availability of {instance_name} in {region}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to support changing the core counts on Azure since at the moment, we provision very beefy 32 core instances but get similar performance with 8 cores for some regions (https://azureprice.net/). An alternative design:

    @staticmethod
    def lookup_valid_instance(region: str, instance_name: str) -> Optional[str]:
        sku_mapping = AzureAuthentication.get_sku_mapping()
        if instance_name in sku_mapping[region]:
            return instance_name
        match = re.match(r"^(?P<base_name>.*)_v(?P<version>\d+)$", instance_name)
        if match:
            base_name = match.group("base_name")
            for version in range(int(match.group("version")), 0, -1):
                test_instance_name = f"{base_name}_v{version}" if version > 1 else base_name
                if test_instance_name in sku_mapping[region]:
                    logger.fs.warning(f"[azure] Instance {instance_name} not found in region {region} but was able to find a similar instance {test_instance_name}")
                    return test_instance_name
        logger.fs.error(f"[azure] Instance {instance_name} not found in region {region} and could not infer a similar instance name.")
        return None



@staticmethod
def get_region_config():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add types: def get_region_config() -> List[string]:

return region_list

@staticmethod
def get_sku_mapping():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add types: def get_sku_mapping() -> Dict[str, List[str]]

@parasj parasj mentioned this pull request May 17, 2022
@parasj parasj linked an issue May 17, 2022 that may be closed by this pull request
@antonzabreyko antonzabreyko merged commit 03cd41b into main May 18, 2022
@antonzabreyko antonzabreyko deleted the dev/anton/azure-config branch May 18, 2022 01:22
parasj pushed a commit that referenced this pull request May 18, 2022
* Azure caches enabled regions

* SKU availability cached

* Azure lookup instance uses cached SKU mapping

* Generalized azure instance type lookup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure regional config
2 participants