Skip to content

Commit

Permalink
feat(k8s_tagger): Added pagination when fetching pods from the k8s API
Browse files Browse the repository at this point in the history
  • Loading branch information
rnishtala-sumo committed Oct 21, 2024
1 parent 8c4f441 commit cf691d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions .changelog/1687.added.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat(k8s_tagger): Added pagination when fetching pods from the k8s API
20 changes: 17 additions & 3 deletions pkg/processor/k8sprocessor/kube/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,23 @@ func newSharedInformer(

func informerListFuncWithSelectors(client kubernetes.Interface, namespace string, ls labels.Selector, fs fields.Selector) cache.ListFunc {
return func(opts metav1.ListOptions) (runtime.Object, error) {
opts.LabelSelector = ls.String()
opts.FieldSelector = fs.String()
return client.CoreV1().Pods(namespace).List(context.Background(), opts)
podList := &api_v1.PodList{}
for {
opts.LabelSelector = ls.String()
opts.FieldSelector = fs.String()
opts.Limit = 200
opts.ResourceVersion = ""
pods, err := client.CoreV1().Pods(namespace).List(context.Background(), opts)
if err != nil {
return nil, err
}
podList.Items = append(podList.Items, pods.Items...)
if pods.Continue == "" {
break
}
opts.Continue = pods.Continue
}
return podList, nil
}

}
Expand Down

0 comments on commit cf691d8

Please sign in to comment.