chore: restore Backup dataSource PVCs in dataprotection
Summary
Implement the dataprotection runtime for PVCs whose dataSourceRef points to a DP Backup.
Changes
- Add DP-specific restore parameter annotations and Backup dataSourceRef helpers.
- Handle Backup-kind PVC data sources in
VolumePopulatorReconciler. - Split PVC handling into restore-data, provision-only, and failed decisions.
- Preserve old TargetVolumes and sharding target semantics, including provision-only for non-restored PVCs.
- Reuse the populate PVC, PV rebind, cleanup, condition, and restore-manager lifecycle.
- Restore system account data as part of the DP runtime path.
- Protect referenced Backups by checking
Cluster.spec.restoreand restore status.
Not included
- No restore ops switch to
Cluster.spec.restore. - No legacy restore annotation constant or plan restore cleanup.
Validation
make generatemake manifestsmake docmake fmtmake lintgo test ./controllers/dataprotectiongo test ./pkg/dataprotection/restore
Codecov Report
:x: Patch coverage is 56.71741% with 654 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 53.13%. Comparing base (7e2fd5a) to head (6abecfd).
Additional details and impacted files
@@ Coverage Diff @@
## main #10245 +/- ##
==========================================
+ Coverage 53.00% 53.13% +0.12%
==========================================
Files 533 533
Lines 61423 62878 +1455
==========================================
+ Hits 32560 33411 +851
- Misses 25581 26051 +470
- Partials 3282 3416 +134
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 53.13% <56.71%> (+0.12%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Found a few blocking issues in the updated implementation:
-
backup_controller.go:694: the legacy restore annotation path is no longer protected. This PR changescheckRestoreInProgressfrom checking theClusterkubeblocks.io/restore-from-backupannotation to only checkingCluster.spec.restore, while the PR still states that the legacy annotation path is preserved. During an existing annotation-based restore, backup jobs can now proceed instead of being delayed. Please keep the old annotation check alongside the newCluster.spec.restorecheck until the legacy path is actually removed. -
volumepopulator_controller.go:237: BackupdataSourceRef.namespaceis ignored.MatchToPopulateacceptsdataSourceRef.kind=Backup, butvalidateRestoreAndBuildMGRresolves the Backup namespace fromapps.kubeblocks.io/restore-source-namespace, falling back to the PVC namespace, and never usespvc.Spec.DataSourceRef.Namespace. IfdataSourceRef.namespaceis set directly, or diverges from the annotation, the populator can restore from the wrong Backup object or fail to find the intended one. Please usedataSourceRef.Namespaceas the canonical source namespace, or validate it matches the annotation before proceeding. -
volumepopulator_controller.go:1713: restored system accounts are not integrated with accountProvision state. This PR restores system account Secrets and marks them withapps.kubeblocks.io/system-account-provisioned, but the existing accountProvision transformer does not read this annotation. On the newCluster.spec.restorepath,transformer_component_account_provision.go:163still only skips create when the old restore annotation exists. Non-init restored accounts can therefore be created again after the Component reaches Running, causing duplicate-account failures or unintended account/password changes. Please make accountProvision recognize restored/provisioned account Secrets, or update the Component accountProvision condition when restoring them.
/approve