Open hzproe opened 4 months ago
Hi @hzproe thanks for your report.
We have a test scenario of vm with instancetype and preferences: https://github.com/kubevirt/kubevirt-velero-plugin/blob/main/tests/vm_backup_test.go#L204
Which passes with no issues in our CI.
Now I still tried to run it again locally and it passed, I tried to change the case of the attributes
as you suggested in your fix and with that the instancetype and preference are not included in the backup (comparing to how it is now which is included, I checked)
Have you tried your solution and it worked for you?
What happened: Restore of VMs failing with missing Controllerrevision message
What you expected to happen: Restore of the VM working fine
How to reproduce it (as minimally and precisely as possible): Create a vm using a script like
apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: ubuntubackup namespace: default spec: running: true dataVolumeTemplates:
Additional context: Add any other context about the problem here.
Environment:
KubeVirt version (use
virtctl version
): Client Version: version.Info{GitVersion:"v1.1.1", GitCommit:"689c0e66cc6893f311dd648ff32e247203b6c96a", GitTreeState:"clean", BuildDate:"2023-12-25T10:58:20Z", GoVersion:"go1.19.9", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{GitVersion:"v1.1.1", GitCommit:"689c0e66cc6893f311dd648ff32e247203b6c96a", GitTreeState:"clean", BuildDate:"2023-12-25T11:56:11Z", GoVersion:"go1.19.9", Compiler:"gc", Platform:"linux/amd64"}Kubernetes version (use
kubectl version
): 09:27 $ kubectl version Client Version: v1.29.0 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.28.4VM or VMI specifications: see above
Cloud provider or hardware configuration: ClusterAPI on Vsphere
OS (e.g. from /etc/os-release): Ubuntu22
Kernel (e.g.
uname -a
): N/AInstall tools: N/A
Others: N/A
Solution:
there is a casesensitive parameter which is evaluated wrongly, see snippet below ... where I have corrected the case of the attributes happy to create a PR if you want
func (p VMBackupItemAction) addVMObjectGraph(vm kvcore.VirtualMachine, extra []velero.ResourceIdentifier) []velero.ResourceIdentifier { if vm.Spec.Instancetype != nil { switch vm.Spec.Instancetype.Kind { //TODO handle VirtualMachineClusterInstancetype //case "virtualmachineinstancetype": case "VirtualMachineInstancetype": <========== p.log.Infof("Adding instance type %s to the backup", vm.Spec.Instancetype.Name) extra = append(extra, velero.ResourceIdentifier{ GroupResource: schema.GroupResource{Group: "instancetype.kubevirt.io", Resource: "virtualmachineinstancetype"}, Namespace: vm.Namespace, Name: vm.Spec.Instancetype.Name, }) extra = append(extra, velero.ResourceIdentifier{ GroupResource: schema.GroupResource{Group: "apps", Resource: "controllerrevisions"}, Namespace: vm.Namespace, Name: vm.Spec.Instancetype.RevisionName, }) } }
}