Kaynağa Gözat

Merge pull request #693 from kubecost/mmd-exporter-only

ComputeCostData: don't return on prometheus errors
Michael Dresser 5 yıl önce
ebeveyn
işleme
85e5195e71
1 değiştirilmiş dosya ile 4 ekleme ve 2 silme
  1. 4 2
      pkg/costmodel/costmodel.go

+ 4 - 2
pkg/costmodel/costmodel.go

@@ -297,14 +297,16 @@ func (cm *CostModel) ComputeCostData(cli prometheusClient.Client, cp costAnalyze
 		}
 
 		// ErrorCollection is an collection of errors wrapped in a single error implementation
-		return nil, ctx.ErrorCollection()
+		// We opt to not return an error for the sake of running as a pure exporter.
+		log.Warningf("ComputeCostData: continuing despite prometheus errors: %s", ctx.ErrorCollection().Error())
 	}
 
 	defer measureTime(time.Now(), profileThreshold, "ComputeCostData: Processing Query Data")
 
 	normalizationValue, err := getNormalization(resNormalization)
 	if err != nil {
-		return nil, fmt.Errorf("Error parsing normalization values from %s: %s", queryNormalization, err.Error())
+		// We opt to not return an error for the sake of running as a pure exporter.
+		log.Warningf("ComputeCostData: continuing despite error parsing normalization values from %s: %s", queryNormalization, err.Error())
 	}
 
 	nodes, err := cm.GetNodeCost(cp)