Skip to content

Reject restores that reference a backup in the Deleting phase#9868

Closed
RoySerbi wants to merge 2 commits into
velero-io:mainfrom
RoySerbi:fix/9790-reject-restore-from-deleting-backup
Closed

Reject restores that reference a backup in the Deleting phase#9868
RoySerbi wants to merge 2 commits into
velero-io:mainfrom
RoySerbi:fix/9790-reject-restore-from-deleting-backup

Conversation

@RoySerbi

@RoySerbi RoySerbi commented Jun 1, 2026

Copy link
Copy Markdown

Please add a summary of your change

When a Backup's Status.Phase is Deleting, its underlying data (object store contents, PV snapshots, pod volume snapshots) may be concurrently removed by the backup deletion controller. Previously validateAndComplete (pkg/controller/restore_controller.go) only verified that the backup existed and that its BackupStorageLocation was available — it never checked Backup.Status.Phase. As a result, a Restore created via spec.backupName against a being-deleted backup was accepted and could begin executing against data that is mid-deletion, leading to a restore that fails part-way through or produces incomplete/corrupt output while still being treated as valid.

This PR adds a phase check immediately after fetchBackupInfo succeeds: if the referenced backup is in the Deleting phase, the restore is rejected with a clear validation error and set to FailedValidation:

backup <name> is being deleted and cannot be used as a restore source

The spec.scheduleName path is unaffected, because mostRecentCompletedBackup already filters to Completed backups.

A table-driven test case was added to TestRestoreReconcile covering this scenario (restore referencing a Deleting-phase backup → FailedValidation with the expected error).

Does your change fix a particular issue?

Fixes #9790

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file (make new-changelog) or comment /kind changelog-not-required on this PR.
  • Updated the corresponding documentation in site/content/docs/main. — Not applicable; this is an internal restore-validation rule with no user-facing documentation surface.

AI assistance disclosure: This change was prepared with AI assistance (Claude, Anthropic). I have personally reviewed and tested it, and I take full responsibility for the contribution. The fix was developed test-first: the new test fails on main (the deleting-phase backup is wrongly accepted and the restore proceeds to download backup contents) and passes after the validation check is added. go vet and gofmt are clean and the existing pkg/controller unit tests continue to pass.

When a backup's Status.Phase is Deleting, its underlying data (object
store contents and volume snapshots) may be concurrently removed by the
backup deletion controller. Previously validateAndComplete only checked
that the backup existed and its BSL was available, so a restore created
against a being-deleted backup was accepted and could fail mid-execution
or produce incomplete output.

Add a phase check after fetchBackupInfo so such restores fail validation
with a clear error. The schedule path is unaffected because it already
selects only Completed backups.

Fixes velero-io#9790

Assisted-by: Claude (Anthropic)
Signed-off-by: RoyS <229624717+RoySerbi@users.noreply.github.com>
@netlify

netlify Bot commented Jun 1, 2026

Copy link
Copy Markdown

👷 Deploy request for velero pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 4403142

Signed-off-by: RoyS <229624717+RoySerbi@users.noreply.github.com>
@RoySerbi

RoySerbi commented Jun 1, 2026

Copy link
Copy Markdown
Author

Closing as a duplicate of #9792, which already addresses #9790 (and more comprehensively, covering all non-usable backup phases rather than only Deleting). Apologies for the overlap — I should have checked the linked PRs first. Thanks @subhramit for the existing work.

@RoySerbi RoySerbi closed this Jun 1, 2026
@RoySerbi RoySerbi deleted the fix/9790-reject-restore-from-deleting-backup branch June 1, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore validation should reject restores from backups in Deleting phase

1 participant