WIP: Fix BoostRepoConnect fallback to use PrepareRepo instead of ConnectToRepo (#8279)#490
Conversation
…ectToRepo (vmware-tanzu#8279) When BoostRepoConnect's Open() fast path fails (e.g., stale local config after BSL prefix change), it falls back to ConnectToRepo which only connects (Init with createNew=false). If no kopia repository exists at the new storage location, this fails with 'repository not initialized in the provided storage'. Fix: Change the fallback from ConnectToRepo to PrepareRepo, which tries to connect first and initializes a new repository if ErrRepositoryNotInitialized is returned — matching the BackupRepository controller's reconciliation behavior. This is complementary to vmware-tanzu#9236 which fixes the controller-side invalidation. This fix addresses the data path fallback so BoostRepoConnect can handle uninitialized repos regardless of controller state. Accepted fix in upstream will be prioritized/preferred over this cherry-pick. Also adds unit tests for: - invalidateBackupReposForBSL() function - BackupRepository identifier update on BSL prefix change (restic and kopia) - Full BSL delete/recreate cycle (PR vmware-tanzu#7380 scenario) - BoostRepoConnect initialization when repo not found at new location Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering> Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
|
Important Review skippedAuto reviews are limited based on label configuration. 🚫 Review skipped — only excluded labels are configured. (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kaovilai The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Note
Accepted fix in upstream vmware-tanzu/velero will be prioritized/preferred over this cherry-pick.
Problem
When
BoostRepoConnect'sOpen()fast path fails (e.g., stale local kopia config after BSL prefix change), it falls back toConnectToRepowhich only connects (InitwithcreateNew=false). If no kopia repository exists at the new storage location, this fails with:This is the error seen in vmware-tanzu/velero#8279.
Root Cause
BoostRepoConnect(pkg/repository/provider/unified_repo.go) falls back toConnectToRepo(connect-only) instead ofPrepareRepo(connect-then-init). The existing invalidation logic (vmware-tanzu#7380) and BackupRepository reconciliation (PrepareRepo) are correct — the bug is only in the backup data path's fallback.Fix
One-line change: swap
ConnectToRepoforPrepareRepoinBoostRepoConnect's fallback path. This ensures that when the local kopia config is stale,BoostRepoConnectwill initialize a new repository at the new location if one doesn't exist — matching the BackupRepository controller's reconciliation behavior.Complementary to
This fix addresses the data path fallback so
BoostRepoConnectcan handle uninitialized repos regardless of controller state.Tests Added
TestInvalidateBackupReposForBSL— verifiesinvalidateBackupReposForBSL()patches matching repos to NotReadyTestCheckNotReadyRepoUpdatesIdentifierOnPrefixChange— restic repo identifier update on prefix changeTestCheckNotReadyRepoKopiaUpdatesIdentifierOnPrefixChange— kopia repo identifier update on prefix changeTestBSLDeleteRecreateWithNewPrefix— full BSL delete/recreate cycle end-to-endTestBoostRepoConnectInitializesWhenRepoNotFound— verifiesBoostRepoConnectinitializes repo when not found at new location