Skip to content

Commit 83fcd72

Browse files
fix(azure/aks): Tighten VM Price Store API Filter to Prevent Timeout (#885)
Co-authored-by: belén <38337779+rooneyshuman@users.noreply.github.com>
1 parent d630955 commit 83fcd72

2 files changed

Lines changed: 2 additions & 23 deletions

File tree

pkg/azure/aks/vm_price_store.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
)
2121

2222
const (
23-
AzurePriceSearchFilter = `serviceName eq 'Virtual Machines' and priceType eq 'Consumption'`
23+
AzurePriceSearchFilter = `serviceName eq 'Virtual Machines' and priceType eq 'Consumption' and contains(productName, 'Virtual Machines') and contains(skuName, 'Low Priority') ne true`
2424
AzureMeterRegion = `'primary'`
2525
DefaultInstanceFamily = "General purpose"
2626

@@ -166,22 +166,6 @@ func (p *VMPriceStore) getPriceInfoFromVmInfo(ctx context.Context, vmInfo *Virtu
166166
return machineSku, nil
167167
}
168168

169-
func (p *VMPriceStore) validateMachinePriceIsRelevantFromSku(ctx context.Context, sku *retailPriceSdk.ResourceSKU) bool {
170-
productName := sku.ProductName
171-
if len(productName) == 0 || !strings.Contains(productName, "Virtual Machines") {
172-
p.logger.LogAttrs(ctx, slog.LevelDebug, "product is not a virtual machine", slog.String("sku", sku.SkuName))
173-
return false
174-
}
175-
176-
skuName := sku.SkuName
177-
if len(skuName) == 0 || strings.Contains(skuName, "Low Priority") {
178-
p.logger.LogAttrs(ctx, slog.LevelDebug, "disregarding low priority aka Spot machines", slog.String("sku", sku.SkuName))
179-
return false
180-
}
181-
182-
return true
183-
}
184-
185169
// PopulateVMPriceStore loads VM retail prices for the given ARM regions into RegionMap.
186170
func (p *VMPriceStore) PopulateVMPriceStore(ctx context.Context, regions []string) bool {
187171
if len(regions) == 0 {
@@ -240,10 +224,6 @@ func (p *VMPriceStore) PopulateVMPriceStore(ctx context.Context, regions []strin
240224
// Track all regions we see in the data
241225
regionsFound[regionName] = true
242226

243-
if !p.validateMachinePriceIsRelevantFromSku(ctx, price) {
244-
continue
245-
}
246-
247227
if _, ok := p.RegionMap[regionName]; !ok {
248228
p.logger.LogAttrs(ctx, slog.LevelInfo, "populating machine prices for region", slog.String("region", regionName))
249229
p.RegionMap[regionName] = make(PriceByPriority)

pkg/azure/aks/vm_price_store_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ func TestPopulateVMPriceStore(t *testing.T) {
7474
{ArmSkuName: "Standard_D4s_v3", SkuName: "D4s v3", ArmRegionName: "westus", ProductName: "Virtual Machines D Series", RetailPrice: 0.1},
7575
{ArmSkuName: "Standard_D8s_v3", SkuName: "D8s v3", ArmRegionName: "centraleurope", ProductName: "Virtual Machines D Series", RetailPrice: 0.1},
7676
{ArmSkuName: "Standard_D16s_v3", SkuName: "D16s v3 Spot", ArmRegionName: "centraleurope", ProductName: "Virtual Machines D Series", RetailPrice: 0.01},
77-
{ArmSkuName: "Standard_D4s_v3", SkuName: "D4s v3 Low Priority", ArmRegionName: "centraleurope", ProductName: "Virtual Machines D Series", RetailPrice: 0.01}, // low priority machines are disregarded
7877
},
7978

8079
timesToCallListPrices: 1,
@@ -242,7 +241,7 @@ func TestDetermineMachinePriority(t *testing.T) {
242241
}{
243242
"OnDemand": {
244243
sku: &retailPriceSdk.ResourceSKU{
245-
SkuName: "Standard_E16pds_v5 Low Priority",
244+
SkuName: "Standard_D16s_v5",
246245
},
247246
expectedPriority: OnDemand,
248247
},

0 commit comments

Comments
 (0)