kubevirt / kubevirt-velero-plugin

Plugin to Velero which automates backing up and restoring KubeVirt/CDI objects
Apache License 2.0
26 stars 26 forks source link

Restore fails after label-based backup due to missing instancetype `ControllerRevision` #258

Open e3b0c442 opened 1 week ago

e3b0c442 commented 1 week ago

What happened: When attempting to restore a backed-up VM, the restore fails with an error similar to the following: error restoring virtualmachines.kubevirt.io/vms/one: admission webhook "virtualmachine-validator.kubevirt.io" denied the request: Failure to find instancetype: controllerrevisions.apps "node1-o1.large-3ae509a7-5446-4119-945d-1eb2a00d00cb-1" not found

What you expected to happen: The ControllerRevision is correctly backed up with the VM when a label is specified, and the restore completes successfully.

How to reproduce it (as minimally and precisely as possible):

  1. Create a VM with a VirtualMachineClusterInstanceType or VirtualMachineInstanceType and an identifying label
  2. Back up the VM with Velero, specifying the label. e.g. velero backup create node1-backup --include-namespaces vms -l name=node1 --snapshot-move-data --wait
  3. Delete the backed-up VM kubectl delete vm node1
  4. Attempt to restore the VM velero restore create --from-backup node1-backup

Additional context: When specifying a label filter, the ControllerRevision resource is not added to the backup, despite being owned by the VirtualMachine resource. Labels applied to the VirtualMachine resource are not propagated down to the ControllerRevision created by KubeVirt.

If the label filter is removed and the entire namespace is backed up, the ControllerRevision resource is included in the backups and subsequently restored successfully..

Environment: