diff --git a/pkg/providers/instancetype/instancetypes.go b/pkg/providers/instancetype/instancetypes.go index a8442b2a7..8e2addb5b 100644 --- a/pkg/providers/instancetype/instancetypes.go +++ b/pkg/providers/instancetype/instancetypes.go @@ -145,12 +145,13 @@ func instanceTypeZones(sku *skewer.SKU, region string) sets.Set[string] { // skewer returns numerical zones, like "1" (as keys in the map); // prefix each zone with "-", to have them match the labels placed on Node (e.g. "westus2-1") // Note this data comes from LocationInfo, then skewer is used to get the SKU info - if hasZonalSupport(region) { - return sets.New(lo.Map(lo.Keys(sku.AvailabilityZones(region)), func(zone string, _ int) string { + // If an offering is non-zonal, the availability zones will be empty. + skuZones := lo.Keys(sku.AvailabilityZones(region)) + if hasZonalSupport(region) && len(skuZones) > 0 { + return sets.New(lo.Map(skuZones, func(zone string, _ int) string { return fmt.Sprintf("%s-%s", region, zone) })...) } - return sets.New("") // empty string means non-zonal offering } diff --git a/pkg/providers/instancetype/suite_test.go b/pkg/providers/instancetype/suite_test.go index 4a65f820c..66d2879db 100644 --- a/pkg/providers/instancetype/suite_test.go +++ b/pkg/providers/instancetype/suite_test.go @@ -343,7 +343,6 @@ var _ = Describe("InstanceType Provider", func() { It("should not include confidential SKUs", func() { Expect(instanceTypes).ShouldNot(ContainElement(WithTransform(getName, Equal("Standard_DC8s_v3")))) }) - }) Context("Filtering GPU SKUs ProviderList(AzureLinux)", func() { var instanceTypes corecloudprovider.InstanceTypes @@ -1186,6 +1185,25 @@ var _ = Describe("InstanceType Provider", func() { vm := azureEnvNonZonal.VirtualMachinesAPI.VirtualMachineCreateOrUpdateBehavior.CalledWithInput.Pop().VM Expect(vm.Zones).To(BeEmpty()) }) + It("should support provisioning non-zonal instance types in zonal regions", func() { + coretest.ReplaceRequirements(nodePool, corev1beta1.NodeSelectorRequirementWithMinValues{ + NodeSelectorRequirement: v1.NodeSelectorRequirement{ + Key: v1.LabelInstanceTypeStable, + Operator: v1.NodeSelectorOpIn, + Values: []string{"Standard_NC6s_v3"}, + }}) + ExpectApplied(ctx, env.Client, nodePool, nodeClass) + + pod := coretest.UnschedulablePod() + ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, coreProvisioner, pod) + + node := ExpectScheduled(ctx, env.Client, pod) + Expect(node.Labels).To(HaveKeyWithValue(v1alpha2.AlternativeLabelTopologyZone, "")) + + Expect(azureEnv.VirtualMachinesAPI.VirtualMachineCreateOrUpdateBehavior.CalledWithInput.Len()).To(Equal(1)) + vm := azureEnv.VirtualMachinesAPI.VirtualMachineCreateOrUpdateBehavior.CalledWithInput.Pop().VM + Expect(vm.Zones).To(BeEmpty()) + }) }) })