Skip to content

Commit

Permalink
Merge pull request kubernetes#95013 from soltysh/fix_context
Browse files Browse the repository at this point in the history
Use pager's context instead of TODO
  • Loading branch information
k8s-ci-robot authored Sep 24, 2020
2 parents 770eb2c + d91a1f7 commit 2d9a0b6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/controller/cronjob/cronjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,18 @@ func (jm *Controller) syncAll() {
js = append(js, *jobTmp)
return nil
})

if err != nil {
utilruntime.HandleError(fmt.Errorf("Failed to extract job list: %v", err))
return
}

klog.V(4).Infof("Found %d jobs", len(js))
cronJobListFunc := func(opts metav1.ListOptions) (runtime.Object, error) {
return jm.kubeClient.BatchV1beta1().CronJobs(metav1.NamespaceAll).List(context.TODO(), opts)
}

jobsByCj := groupJobsByParent(js)
klog.V(4).Infof("Found %d groups", len(jobsByCj))
err = pager.New(pager.SimplePageFunc(cronJobListFunc)).EachListItem(context.Background(), metav1.ListOptions{}, func(object runtime.Object) error {

err = pager.New(func(ctx context.Context, opts metav1.ListOptions) (runtime.Object, error) {
return jm.kubeClient.BatchV1beta1().CronJobs(metav1.NamespaceAll).List(ctx, opts)
}).EachListItem(context.Background(), metav1.ListOptions{}, func(object runtime.Object) error {
cj, ok := object.(*batchv1beta1.CronJob)
if !ok {
return fmt.Errorf("expected type *batchv1beta1.CronJob, got type %T", cj)
Expand Down

0 comments on commit 2d9a0b6

Please sign in to comment.