Browse Source

Merge pull request #886 from kubecost/bolt/pv-hourly-cost-fix

Omit PV Hourly Metrics for !Available and !Bound
Matt Bolt 4 years ago
parent
commit
307ba8600a
1 changed files with 5 additions and 0 deletions
  1. 5 0
      pkg/costmodel/metrics.go

+ 5 - 0
pkg/costmodel/metrics.go

@@ -530,6 +530,11 @@ func (cmme *CostModelMetricsEmitter) Start() bool {
 
 			pvs := cmme.KubeClusterCache.GetAllPersistentVolumes()
 			for _, pv := range pvs {
+				// Omit pv_hourly_cost if the volume status is failed
+				if pv.Status.Phase == v1.VolumeFailed {
+					continue
+				}
+
 				parameters, ok := storageClassMap[pv.Spec.StorageClassName]
 				if !ok {
 					klog.V(4).Infof("Unable to find parameters for storage class \"%s\". Does pv \"%s\" have a storageClassName?", pv.Spec.StorageClassName, pv.Name)