#10604·velero

Context is not propagated in backup repository BSL invalidation handler

Author: abhayrajjais01Created Sep 29, 2026Updated Sep 29, 2026

What steps did you take and what happened: In pkg/controller/backup_repository_controller.go, invalidateBackupReposForBSL(ctx context.Context, bslObj client.Object) receives a ctx context.Context parameter from the controller-runtime event handler:

go
func (r *BackupRepoReconciler) invalidateBackupReposForBSL(ctx context.Context, bslObj client.Object) []reconcile.Request

However, inside the function, ctx is ignored in two places and replaced with context.TODO() and context.Background():

  1. Line 149:
go
if err := r.List(context.TODO(), list, options); err != nil {
  1. Line 157:
go
if err := r.patchBackupRepository(context.Background(), &list.Items[i], repoNotReady("re-establish on BSL change, create or delete")); err != nil {

Because context.TODO() and context.Background() are passed instead of the caller's ctx, cancellation signals and deadlines (for example, when the controller manager is shutting down or the reconcile event context is canceled) are bypassed during the BackupRepository listing and patching operations.

What did you expect to happen: The caller-provided ctx should be passed to r.List(ctx, list, options) and r.patchBackupRepository(ctx, &list.Items[i], ...) so context cancellation and deadlines are properly honored.

The following information will help us better understand what's going on: N/A (Code health / context propagation issue in backup repository controller)

Anything else you would like to add: I have identified the fix and would like to submit a PR along with unit test coverage for invalidateBackupReposForBSL.

Environment:

  • Velero version (use velero version): main branch (v1.17 / v1.18 development)
  • Velero features (use velero client config get features): N/A
  • Kubernetes version (use kubectl version): N/A
  • Kubernetes installer & version: N/A
  • Cloud provider or hardware configuration: N/A
  • OS (e.g. from /etc/os-release): Linux / all platforms