Skip to content

Commit 09aa616

Browse files
iamanmolmHarness
authored andcommitted
feat: [CCM-23530]: Fix prefix issue in machine types (#13)
* feat: [CCM-23530]: Fix prefix issue in machine types
1 parent 7af4e40 commit 09aa616

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

internal/cloudinfo/providers/google/cloudinfo.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,14 @@ func (g *GceInfoer) getPrice() (map[string]map[string]map[string]float64, map[st
311311
return nil, nil, fmt.Errorf("compute Engine service not found")
312312
}
313313

314+
// CT3, CT3P, "CT5LP", "CT5P", "CT6E", "X4" not present in https://cloud.google.com/compute/vm-instance-pricing?hl=en
315+
// F1, G1 already considered as G1Small, F1Micro
316+
// A4 do not have any ondemand/ spot price but only reserved price
317+
// Pricing for M1, M2 would fall to default
314318
standardMachineTypes := []string{
315-
"A2", "A3", "A4", "C2", "C2D", "C3", "C3D", "C4", "C4A", "C4D",
316-
"CT3", "CT3P", "CT5LP", "CT5P", "CT6E", "E2", "F1", "G1", "G2",
317-
"M1", "M2", "M3", "M4", "N1", "N2", "N2D", "N4", "T2A", "T2D",
319+
"A2", "A3", "A4", "C2D", "C2", "C3D", "C3", "C4A", "C4D", "C4",
320+
"CT3P", "CT3", "CT5LP", "CT5P", "CT6E", "E2", "F1", "G1", "G2",
321+
"M1", "M2", "M3", "M4", "N1", "N2D", "N2", "N4", "T2A", "T2D",
318322
"X4", "Z3",
319323
}
320324

@@ -366,9 +370,9 @@ func (g *GceInfoer) getPrice() (map[string]map[string]map[string]float64, map[st
366370
}
367371
}
368372
}
369-
if sku.Category.ResourceGroup == "RAM" || sku.Category.ResourceGroup == "CPU" {
373+
if (sku.Category.ResourceGroup == "RAM" || sku.Category.ResourceGroup == "CPU") && (sku.Category.UsageType == "OnDemand" || sku.Category.UsageType == "Preemptible") {
370374
for _, standardMachineType := range standardMachineTypes {
371-
if strings.Contains(sku.Description, standardMachineType) {
375+
if strings.Contains(sku.Description, standardMachineType) && !strings.Contains(sku.Description, "Sole Tenancy") && !strings.Contains(sku.Description, "Custom") {
372376
priceInUsd, err := g.priceInUsd(sku.PricingInfo)
373377
if err != nil {
374378
return err

0 commit comments

Comments
 (0)