Skip to content

Commit d91a1f7

Browse files
committed
Use pager's context instead of TODO
1 parent 8eda21e commit d91a1f7

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pkg/controller/cronjob/cronjob_controller.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,18 @@ func (jm *Controller) syncAll() {
119119
js = append(js, *jobTmp)
120120
return nil
121121
})
122-
123122
if err != nil {
124123
utilruntime.HandleError(fmt.Errorf("Failed to extract job list: %v", err))
125124
return
126125
}
127-
128126
klog.V(4).Infof("Found %d jobs", len(js))
129-
cronJobListFunc := func(opts metav1.ListOptions) (runtime.Object, error) {
130-
return jm.kubeClient.BatchV1beta1().CronJobs(metav1.NamespaceAll).List(context.TODO(), opts)
131-
}
132127

133128
jobsByCj := groupJobsByParent(js)
134129
klog.V(4).Infof("Found %d groups", len(jobsByCj))
135-
err = pager.New(pager.SimplePageFunc(cronJobListFunc)).EachListItem(context.Background(), metav1.ListOptions{}, func(object runtime.Object) error {
130+
131+
err = pager.New(func(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error) {
132+
return jm.kubeClient.BatchV1beta1().CronJobs(metav1.NamespaceAll).List(ctx, opts)
133+
}).EachListItem(context.Background(), metav1.ListOptions{}, func(object runtime.Object) error {
136134
cj, ok := object.(*batchv1beta1.CronJob)
137135
if !ok {
138136
return fmt.Errorf("expected type *batchv1beta1.CronJob, got type %T", cj)

0 commit comments

Comments
 (0)