diff --git a/pkg/registry/apis/provisioning/jobs/export/resources.go b/pkg/registry/apis/provisioning/jobs/export/resources.go index 2cfbf138e11..6a42a6593ff 100644 --- a/pkg/registry/apis/provisioning/jobs/export/resources.go +++ b/pkg/registry/apis/provisioning/jobs/export/resources.go @@ -41,13 +41,17 @@ func (r *exportJob) loadResourcesFromAPIServer(ctx context.Context, kind schema. } var continueToken string - for { + for ctx.Err() == nil { list, err := client.List(ctx, metav1.ListOptions{Limit: 100, Continue: continueToken}) if err != nil { return fmt.Errorf("error executing list: %w", err) } for _, item := range list.Items { + if ctx.Err() != nil { + return ctx.Err() + } + r.progress.Record(ctx, r.write(ctx, &item)) if err := r.progress.TooManyErrors(); err != nil { return err @@ -60,7 +64,7 @@ func (r *exportJob) loadResourcesFromAPIServer(ctx context.Context, kind schema. } } - return nil + return ctx.Err() } func (r *exportJob) write(ctx context.Context, obj *unstructured.Unstructured) jobs.JobResourceResult { diff --git a/pkg/registry/apis/provisioning/jobs/sync/worker.go b/pkg/registry/apis/provisioning/jobs/sync/worker.go index ebeacbe2e29..1778766d032 100644 --- a/pkg/registry/apis/provisioning/jobs/sync/worker.go +++ b/pkg/registry/apis/provisioning/jobs/sync/worker.go @@ -258,6 +258,9 @@ func (r *syncJob) applyChanges(ctx context.Context, changes []ResourceFileChange r.progress.SetMessage(ctx, "replicating changes") for _, change := range changes { + if ctx.Err() != nil { + return ctx.Err() + } if err := r.progress.TooManyErrors(); err != nil { return err } @@ -341,6 +344,9 @@ func (r *syncJob) applyVersionedChanges(ctx context.Context, repo repository.Ver r.progress.SetMessage(ctx, "replicating versioned changes") for _, change := range diff { + if ctx.Err() != nil { + return ctx.Err() + } if err := r.progress.TooManyErrors(); err != nil { return err }