diff --git a/ocp-metadata/ocp-metadata.go b/ocp-metadata/ocp-metadata.go index 0f8254b..d19b849 100644 --- a/ocp-metadata/ocp-metadata.go +++ b/ocp-metadata/ocp-metadata.go @@ -96,12 +96,17 @@ func (meta *Metadata) GetCurrentPodCount() (int, error) { if err != nil { return podCount, err } - for _, node := range nodeList.Items { - podList, err := meta.clientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{FieldSelector: "status.phase=Running,spec.nodeName=" + node.Name}) - if err != nil { - return podCount, err + podList, err := meta.clientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{FieldSelector: "status.phase=Running"}) + if err != nil { + return podCount, err + } + for _, pod := range podList.Items { + for _, node := range nodeList.Items { + if pod.Spec.NodeName == node.Name { + podCount++ + break + } } - podCount += len(podList.Items) } return podCount, nil }