refactor(backups): stop annotating restored PVCs for CDI claim adoption

CDI decides whether a DataVolume may adopt an existing claim from the
cdi.kubevirt.io/allowClaimAdoption annotation on the DataVolume, or
from the DataVolumeClaimAdoption feature gate. It never reads the
annotation on the PVC. The Velero modifier rule that stamped it on
every restored PVC in both the VM and the Kubernetes restore strategy
therefore changed nothing, while the Kubernetes strategy comment and
the VM restore example described it as part of what lets CDI adopt.

Drop the PVC rule from both strategies. Adoption still rests on the
annotation the vm-disk chart puts on its DataVolume and, for tenant
clusters, on the rule that sets it on restored DataVolumes, which a
test now pins as the only rule of the volumes phase.

Without that rule an in-place VM strategy restore of a VMDisk, or of
a VMInstance with no recorded IP and MAC to keep, has no modifier rule
left. Velero fails validation of a Restore whose modifier ConfigMap
has an empty rule list, so in that case no ConfigMap is created and
the Restore carries no resource modifier.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-25 12:43:29 +03:00
1 parent ba0ff0f8e8
commit faaa2b7f2c
6 files changed
+72 -40

No files matched your search

@@ -32,12 +32,13 @@ The backup controller performs the following steps automatically:
Velero restores them.
5. **Creates Velero Restore** — restores resources from the backup with:
- `existingResourcePolicy: update` to overwrite existing objects.
- 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.
- OVN IP/MAC annotations to preserve the VM's network identity.
After the Velero Restore completes, the HelmReleases resume and the VM boots
with the restored disk data while retaining its original IP and MAC addresses.
CDI adopts the restored PVC because the vm-disk chart sets `cdi.kubevirt.io/allowClaimAdoption=true` on the DataVolume that Flux recreates once the HelmRelease resumes.
### Reclaiming the kept disks
With `keepOriginalPVC: true`, the default, step 3 switches each disk's PV to the `Retain` reclaim policy so that it outlives the PVC it is renamed from. Nothing removes the `-orig` PVCs or sets the policy back afterwards: they stay until an operator deletes them.