Explorar o código

only charge running pods

AjayTripathy %!s(int64=6) %!d(string=hai) anos
pai
achega
2c1922e85c
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      costmodel/costmodel.go

+ 6 - 0
costmodel/costmodel.go

@@ -352,6 +352,9 @@ func ComputeCostData(cli prometheusClient.Client, clientset kubernetes.Interface
 	}
 	currentContainers := make(map[string]v1.Pod)
 	for _, pod := range podlist.Items {
+		if pod.Status.Phase != "Running" {
+			continue
+		}
 		cs, err := newContainerMetricsFromPod(pod)
 		if err != nil {
 			return nil, err
@@ -1052,6 +1055,9 @@ func ComputeCostDataRange(cli prometheusClient.Client, clientset kubernetes.Inte
 	}
 	currentContainers := make(map[string]v1.Pod)
 	for _, pod := range podlist.Items {
+		if pod.Status.Phase != "Running" {
+			continue
+		}
 		cs, err := newContainerMetricsFromPod(pod)
 		if err != nil {
 			return nil, err