Răsfoiți Sursa

Merge pull request #996 from kubecost/kaelan-aznorwayfix

Fix Azure norwayeast instance pricing not being parsed correctly
Kaelan Patel 4 ani în urmă
părinte
comite
c3079b1139
2 a modificat fișierele cu 8 adăugiri și 1 ștergeri
  1. 5 1
      pkg/cloud/azureprovider.go
  2. 3 0
      pkg/costmodel/router.go

+ 5 - 1
pkg/cloud/azureprovider.go

@@ -59,6 +59,7 @@ var (
 		"uk": "uk",
 		"us": "us",
 		"za": "southafrica",
+		"no": "norway",
 	}
 
 	//mtBasic, _     = regexp.Compile("^BASIC.A\\d+[_Promo]*$")
@@ -790,12 +791,14 @@ func (az *Azure) DownloadPricingData() error {
 	klog.Infof("Using ratecard query %s", rateCardFilter)
 	result, err := rcClient.Get(context.TODO(), rateCardFilter)
 	if err != nil {
+		klog.Warningf("Error in pricing download query from API")
 		az.RateCardPricingError = err
 		return err
 	}
 	allPrices := make(map[string]*AzurePricing)
 	regions, err := getRegions("compute", sClient, providersClient, config.AzureSubscriptionID)
 	if err != nil {
+		klog.Warningf("Error in pricing download regions from API")
 		az.RateCardPricingError = err
 		return err
 	}
@@ -891,6 +894,7 @@ func (az *Azure) DownloadPricingData() error {
 				for _, instanceType := range instanceTypes {
 
 					key := fmt.Sprintf("%s,%s,%s", region, instanceType, usageType)
+
 					allPrices[key] = &AzurePricing{
 						Node: &Node{
 							Cost:         priceStr,
@@ -1446,4 +1450,4 @@ func parseAzureSubscriptionID(id string) string {
 	}
 	// Return empty string if an account could not be parsed from provided string
 	return ""
-}
+}

+ 3 - 0
pkg/costmodel/router.go

@@ -358,6 +358,9 @@ func (a *Accesses) RefreshPricingData(w http.ResponseWriter, r *http.Request, ps
 	w.Header().Set("Access-Control-Allow-Origin", "*")
 
 	err := a.CloudProvider.DownloadPricingData()
+	if err != nil {
+		klog.V(1).Infof("Error refreshing pricing data: %s", err.Error())
+	}
 
 	w.Write(WrapData(nil, err))
 }