Merge pull request #127 from zryfish/fix_pods_count

only non-terminated pods will be counted when counting node pods
This commit is contained in:
zryfish
2018-06-28 15:57:11 +08:00
committed by GitHub

View File

@@ -173,10 +173,11 @@ func FormatNodeMetrics(nodeName string) NodeMetrics {
return resultNode
}
// Count non-terminated pods only
func GetPodCountOnNode(nodeName string) int {
k8sClient := client.NewK8sClient()
options := metav1.ListOptions{
FieldSelector: "spec.nodeName=" + nodeName,
FieldSelector: "spec.nodeName=" + nodeName + ",status.phase!=Failed,status.phase!=Succeeded",
}
podList, err := k8sClient.CoreV1().Pods("").List(options)