소스 검색

only charge running pods

AjayTripathy 6 년 전
부모
커밋
2c1922e85c
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  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