From 70bd0771ca51db6d50146407eb2fd6058e7b5edc Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Wed, 26 Jun 2024 11:33:49 +0300 Subject: [PATCH] list only running pods Signed-off-by: David Wertenteil --- pkg/cleanup/discovery.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cleanup/discovery.go b/pkg/cleanup/discovery.go index 3a5ef28e0..b05e2f25f 100644 --- a/pkg/cleanup/discovery.go +++ b/pkg/cleanup/discovery.go @@ -160,7 +160,9 @@ func (h *KubernetesAPI) fetchWlidsFromRunningWorkloads(resourceMaps *ResourceMap } func (h *KubernetesAPI) fetchInstanceIdsAndImageIdsAndReplicasFromRunningPods(resourceMaps *ResourceMaps) error { - pods, err := h.Client.Resource(schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}).List(context.TODO(), metav1.ListOptions{}) + pods, err := h.Client.Resource(schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}).List(context.TODO(), metav1.ListOptions{ + FieldSelector: "status.phase=Running", + }) if err != nil { return fmt.Errorf("failed to list pods: %w", err) }