mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Merge pull request #95013 from soltysh/fix_context
Use pager's context instead of TODO
This commit is contained in:
commit
2d9a0b64d1
@ -119,20 +119,18 @@ func (jm *Controller) syncAll() {
|
|||||||
js = append(js, *jobTmp)
|
js = append(js, *jobTmp)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utilruntime.HandleError(fmt.Errorf("Failed to extract job list: %v", err))
|
utilruntime.HandleError(fmt.Errorf("Failed to extract job list: %v", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(4).Infof("Found %d jobs", len(js))
|
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)
|
jobsByCj := groupJobsByParent(js)
|
||||||
klog.V(4).Infof("Found %d groups", len(jobsByCj))
|
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)
|
cj, ok := object.(*batchv1beta1.CronJob)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("expected type *batchv1beta1.CronJob, got type %T", cj)
|
return fmt.Errorf("expected type *batchv1beta1.CronJob, got type %T", cj)
|
||||||
|
Loading…
Reference in New Issue
Block a user