Skip to content

Commit

Permalink
[PLAT-12558]Create Provider times out after 3h because querying insta…
Browse files Browse the repository at this point in the history
…nce types in Azure is hung

Summary:
It looks like we are using an older deprecated API for [[ https://learn.microsoft.com/en-us/azure/virtual-machines/sizes | Getting VM Sizes with Their Costs ]].
Instead, we should be using [[ https://learn.microsoft.com/en-us/rest/api/compute/resource-skus/list?view=rest-compute-2023-10-02&tabs=HTTP | ComputeManagementClient::resource_skus_list ]].

Test Plan: Tested manually and the azu provider creation and universe is successful. Yet to test on the time crunch.

Reviewers: svarshney, daniel

Reviewed By: svarshney

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D33145
  • Loading branch information
rohita committed Mar 21, 2024
1 parent d457fc4 commit 3c20cf3
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions managed/devops/opscli/ybops/cloud/azure/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,17 @@ def get_zone_to_subnets(self, vnet, region):
subnet = self.network().get_default_subnet(vnet)
return {zone: subnet for zone in zones}

def parse_vm_info(self, vm):
def parse_vm_info(self, capabilities):
vm_info = {}
vm_info["numCores"] = vm.get("numberOfCores")
vm_info["memSizeGb"] = float(vm.get("memoryInMB")) / 1000.0
vm_info["maxDiskCount"] = vm.get("maxDataDiskCount")
for capability in capabilities:
name = capability.name
value = capability.value
if name == "vCPUs":
vm_info["numCores"] = int(value or 0)
elif name == "MemoryGB":
vm_info["memSizeGb"] = float(value or 0)
elif name == "MaxDataDiskCount":
vm_info["maxDiskCount"] = int(value or 0)
vm_info['prices'] = {}
return vm_info

Expand All @@ -1006,15 +1012,22 @@ def get_instance_types(self, regions):

all_vms = {}
# Base list of VMs to check for.
vm_list = [vm.serialize() for vm in
self.compute_client.virtual_machine_sizes.list(location=regions[0])]
vm_list = self.compute_client.resource_skus.list(filter="location eq '{}'"
.format(regions[0]))
for vm in vm_list:
vm_size = vm.get("name")
# We only care about virtual machines
if vm.resource_type != "virtualMachines":
continue
# No capabilities
capabilities = vm.capabilities
if not capabilities:
continue
vm_size = vm.name
# We only care about VMs that support Premium storage. Promo is pricing special.
if (vm_size.startswith(burstable_prefix) or not regex.match(vm_size)
or vm_size.endswith("Promo")):
continue
vm_info = self.parse_vm_info(vm)
vm_info = self.parse_vm_info(capabilities)
if vm_info["memSizeGb"] < MIN_MEM_SIZE_GB or vm_info["numCores"] < MIN_NUM_CORES:
continue
all_vms[vm_size] = vm_info
Expand Down

0 comments on commit 3c20cf3

Please sign in to comment.