Kaynağa Gözat

Add check to avoid silent fail in logs for download

Kaelan Patel 4 yıl önce
ebeveyn
işleme
a796c4ff1a
2 değiştirilmiş dosya ile 25 ekleme ve 1 silme
  1. 22 1
      pkg/cloud/azureprovider.go
  2. 3 0
      pkg/costmodel/router.go

+ 22 - 1
pkg/cloud/azureprovider.go

@@ -789,13 +789,16 @@ func (az *Azure) DownloadPricingData() error {
 
 	klog.Infof("Using ratecard query %s", rateCardFilter)
 	result, err := rcClient.Get(context.TODO(), rateCardFilter)
+	//klog.Infof("result meters valid %t", result.Meters != nil)
 	if err != nil {
+		klog.Infof("Error in pricing download query")
 		az.RateCardPricingError = err
 		return err
 	}
 	allPrices := make(map[string]*AzurePricing)
 	regions, err := getRegions("compute", sClient, providersClient, config.AzureSubscriptionID)
 	if err != nil {
+		klog.Infof("Error in pricing download regions")
 		az.RateCardPricingError = err
 		return err
 	}
@@ -808,6 +811,8 @@ func (az *Azure) DownloadPricingData() error {
 		meterCategory := *v.MeterCategory
 		meterSubCategory := *v.MeterSubCategory
 
+		//klog.Infof("MeterName: %s", meterName)
+
 		region, err := toRegionID(meterRegion, regions)
 		if err != nil {
 			continue
@@ -919,6 +924,14 @@ func (az *Azure) DownloadPricingData() error {
 	}
 
 	az.Pricing = allPrices
+
+	klog.Infof("--AZURE PRICING RESULTS IN DOWNLOAD--")
+
+	for key, _ := range az.Pricing {
+		//klog.Infof("KEY: %s has Node pricing of %s: %s and PV pricing of %s.", key, azp.Node.Region, azp.Node.InstanceType, azp.PV.Class)
+		klog.Infof("THIS: %s", key)
+	}
+
 	az.RateCardPricingError = nil
 	return nil
 }
@@ -991,6 +1004,14 @@ func (az *Azure) NodePricing(key Key) (*Node, error) {
 		return n.Node, nil
 	}
 	klog.V(1).Infof("[Warning] no pricing data found for %s: %s", azKey.Features(), azKey)
+
+	klog.Infof("--AZURE PRICING RESULTS IN NODE PRICING--")
+
+	for key, _ := range az.Pricing {
+		//klog.Infof("KEY: %s has Node pricing of %s: %s and PV pricing of %s.", key, azp.Node.Region, azp.Node.InstanceType, azp.PV.Class)
+		klog.Infof("THIS: %s", key)
+	}
+
 	c, err := az.GetConfig()
 	if err != nil {
 		return nil, fmt.Errorf("No default pricing data available")
@@ -1433,4 +1454,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))
 }