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:
@@ -173,10 +173,11 @@ func FormatNodeMetrics(nodeName string) NodeMetrics {
|
|||||||
return resultNode
|
return resultNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count non-terminated pods only
|
||||||
func GetPodCountOnNode(nodeName string) int {
|
func GetPodCountOnNode(nodeName string) int {
|
||||||
k8sClient := client.NewK8sClient()
|
k8sClient := client.NewK8sClient()
|
||||||
options := metav1.ListOptions{
|
options := metav1.ListOptions{
|
||||||
FieldSelector: "spec.nodeName=" + nodeName,
|
FieldSelector: "spec.nodeName=" + nodeName + ",status.phase!=Failed,status.phase!=Succeeded",
|
||||||
}
|
}
|
||||||
|
|
||||||
podList, err := k8sClient.CoreV1().Pods("").List(options)
|
podList, err := k8sClient.CoreV1().Pods("").List(options)
|
||||||
|
|||||||
Reference in New Issue
Block a user