chore: support dataprotection restore API decoupling#10192
Conversation
|
Auto Cherry-pick Instructions |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10192 +/- ##
==========================================
+ Coverage 52.47% 52.60% +0.12%
==========================================
Files 532 533 +1
Lines 61230 62459 +1229
==========================================
+ Hits 32133 32855 +722
- Misses 25828 26231 +403
- Partials 3269 3373 +104
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if !apierrors.IsNotFound(err) { | ||
| return intctrlutil.RequeueWithError(err, reqCtx.Log, "") | ||
| } | ||
| target, err = r.buildTargetCluster(reqCtx, clusterRestore, backup, restoreTime) |
There was a problem hiding this comment.
clusterRestore need refer cluster.spec to create cluster, not only from backup snapshot
| // | ||
| // +kubebuilder:pruning:PreserveUnknownFields | ||
| // +kubebuilder:validation:Required | ||
| Spec runtime.RawExtension `json:"spec"` |
There was a problem hiding this comment.
why not use cluster spec ?
…pport/dp-restore-api-decoupling # Conflicts: # pkg/controller/component/workload_test.go
weicao
left a comment
There was a problem hiding this comment.
DP VolumePopulator review: one blocker in the new Backup-kind PVC path.
In Populate, populatePVC is only assigned inside the for _, v := range restoreMgr.PrepareDataBackupSets loop, but after the loop we always call rebindPVCAndPV(reqCtx, populatePVC, pvc). If the restore decision chooses RestoreData while ValidateAndInitRestoreMGR produces zero PrepareDataBackupSets, this will panic on populatePVC.Spec.VolumeName.
This can happen in the new path because decidePVCRestore chooses RestoreData from backup.Status.BackupMethod.TargetVolumes containing the PVC volume, while RestoreManager.SetBackupSets only appends a prepareData backup set when the backup uses volume snapshot or the ActionSet has a prepareData stage. A target volume without a usable prepareData path should fail closed before Populate, not reach a nil dereference.
Please add an explicit guard after restore manager init, for example when decision.mode == pvcRestoreModeRestoreData && len(restoreMgr.PrepareDataBackupSets) == 0, return a fatal error with a clear message, plus a unit test for the Backup-kind PVC path.
Summary
This PR switches cluster restore to the
Cluster.spec.restoreintent flow and removes the previous apps-owned DP restore execution path.The restore flow now uses explicit Kubernetes APIs:
Clusterwithspec.restorespec.dataSourceRef.kind=Backupplus apps-owned restore metadata annotationsThis keeps apps and ops interacting with data protection through API contracts rather than through controller-internal DP restore calls.
Design
apps.kubeblocks.io/v1.Cluster.spec.restoreas the user-facing restore intent.spec.restore; it no longer writeskubeblocks.io/restore-from-backup.Cluster.spec.restoreinto generic PVC restore metadata:PVC.spec.dataSourceRef.apiGroupPVC.spec.dataSourceRef.kindPVC.spec.dataSourceRef.namedataSourceRefpoints atdataprotection.kubeblocks.io/Backup.Changes
Cluster.spec.restore, restore source fields, PITR string, andparameters map[string]stringto the apps v1 API.Cluster.spec.restoreinstead of the legacy restore annotation and to wait on restore condition plus target Cluster phase.Cluster.spec.restore.Out of Scope
Validation
make docgo test ./controllers/dataprotection -run TestAPIsgo test ./pkg/operations -run TestAPIsgo test ./controllers/apps/cluster/...go test ./controllers/apps/component/...go test ./pkg/controller/component ./controllers/apps/cluster -run 'Test(...)'git diff --check