Skip to content

Commit 691d7bc

Browse files
docs(backups): say CDI adopts a restored PVC through the DataVolume
The restore controller and the user-restore example described the allowClaimAdoption annotation its resource modifiers put on restored PVCs as what lets CDI adopt them. CDI v1.66 reads that annotation only on the DataVolume; on a PVC it reads nothing but createdForDataVolume. Adoption rests on the vm-disk chart annotating the DataVolume Flux recreates, and a reader trusting the PVC rule could rely on it for a restore without such a DataVolume, or drop the DataVolume annotation as redundant. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <[email protected]> (cherry picked from commit b5d7e43)
1 parent 1152de7 commit 691d7bc

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎examples/backups/vmi/scenario-user-restore.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ The backup controller performs the following steps automatically:
3232
Velero restores them.
3333
5. **Creates Velero Restore** — restores resources from the backup with:
3434
- `existingResourcePolicy: update` to overwrite existing objects.
35-
- Resource modifier rules that add `cdi.kubevirt.io/allowClaimAdoption=true`
36-
to restored PVCs so CDI can adopt them.
35+
- Resource modifier rules that add `cdi.kubevirt.io/allowClaimAdoption=true` to restored PVCs. CDI does not read that annotation on a PVC: what lets it adopt the restored PVC is the same annotation, which the vm-disk chart sets on the DataVolume Flux recreates once the HelmRelease resumes.
3736
- OVN IP/MAC annotations to preserve the VM's network identity.
3837

3938
After the Velero Restore completes, the HelmReleases resume and the VM boots

‎internal/backupcontroller/velerostrategy_controller.go‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,9 @@ func (r *BackupJobReconciler) collectUnderlyingResources(ctx context.Context, ap
380380
// the live PVC aside and delete the DataVolume, so the restored PVC is
381381
// created fresh under the original name. The HelmRelease is suspended only
382382
// until Velero restores it; Flux then recreates the DataVolume and CDI
383-
// adopts the restored PVC through the allowClaimAdoption annotation the
384-
// restore's resource modifiers set. A standalone VMDisk has no VM, so there
385-
// is no IP/MAC to collect.
383+
// adopts the restored PVC because the vm-disk chart sets allowClaimAdoption
384+
// on that DataVolume. A standalone VMDisk has no VM, so there is no IP/MAC
385+
// to collect.
386386
if appKind == vmDiskAppKind {
387387
return marshalUnderlyingResources(vmInstanceResources{
388388
DataVolumes: []backupsv1alpha1.DataVolumeResource{{
@@ -882,8 +882,11 @@ func marshalPatchData(v any) (string, error) {
882882

883883
// createResourceModifiersConfigMap creates a Velero resource modifiers ConfigMap
884884
// that patches VM resources during restore:
885-
// - PVC adoption: always adds cdi.kubevirt.io/allowClaimAdoption=true to all
886-
// restored PVCs so CDI can adopt them when a HelmRelease of VMDisk recreates a DV.
885+
// - PVC adoption: adds cdi.kubevirt.io/allowClaimAdoption=true to all
886+
// restored PVCs. CDI v1.66 does not read it there, only on the DataVolume,
887+
// so adoption of a restored PVC rests on the vm-disk chart annotating the
888+
// DataVolume it recreates. Without it, CDI refuses that DataVolume unless
889+
// the DataVolumeClaimAdoption feature gate is on.
887890
// - OVN IP/MAC: sets OVN annotations on the VirtualMachine for correct ssh access to restored VM.
888891
func (r *RestoreJobReconciler) createResourceModifiersConfigMap(ctx context.Context, restoreJob *backupsv1alpha1.RestoreJob, backup *backupsv1alpha1.Backup, ur *runtime.RawExtension, target restoreTarget, opts RestoreOptions) (*corev1.ConfigMap, error) {
889892
logger := getLogger(ctx)
@@ -892,7 +895,7 @@ func (r *RestoreJobReconciler) createResourceModifiersConfigMap(ctx context.Cont
892895

893896
var rules []resourceModifierRule
894897

895-
// PVC adoption: allow CDI to adopt restored PVCs when the HelmRelease recreates a DV.
898+
// Inert for CDI, which reads allowClaimAdoption only on the DataVolume.
896899
pvcPatch, err := marshalPatchData(map[string]any{
897900
"metadata": map[string]any{
898901
"annotations": map[string]string{

0 commit comments

Comments
 (0)