Skip to content

Commit 1b2473a

Browse files
authored
Merge pull request kubernetes#3744 from jbartosik/get-only-running-pods
Watch only pods in state Running and Unknown
2 parents be3b7ce + 84fb751 commit 1b2473a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,14 @@ func watchEvictionEvents(evictedEventChan <-chan watch.Event, observer oom.Obser
172172

173173
// Creates clients watching pods: PodLister (listing only not terminated pods).
174174
func newPodClients(kubeClient kube_client.Interface, resourceEventHandler cache.ResourceEventHandler, namespace string) v1lister.PodLister {
175-
selector := fields.ParseSelectorOrDie("status.phase!=" + string(apiv1.PodPending))
175+
// We are interested in pods which are Running or Unknown (in case the pod is
176+
// running but there are some transient errors we don't want to delete it from
177+
// our model).
178+
// We don't want to watch Pending, Succeeded, or Failed failed pods because we
179+
// know they're not generating any usage.
180+
// Filter
181+
statusFilter := fmt.Sprintf("status.phase!=%s,status.phase!=%s,status.phase!=%s", apiv1.PodPending, apiv1.PodSucceeded, apiv1.PodFailed)
182+
selector := fields.ParseSelectorOrDie(statusFilter)
176183
podListWatch := cache.NewListWatchFromClient(kubeClient.CoreV1().RESTClient(), "pods", namespace, selector)
177184
indexer, controller := cache.NewIndexerInformer(
178185
podListWatch,

0 commit comments

Comments
 (0)