@@ -147,10 +147,10 @@ func (v *VirtualMachineHandler) ProcessRestore(ctx context.Context) error {
147
147
}
148
148
149
149
// // Always clean up VMBDAs first, regardless of VM state
150
- // err = v.deleteCurrentVirtualMachineBlockDeviceAttachments(ctx, vm.Name, vm.Namespace, v.restoreUID )
151
- // if err != nil {
152
- // return err
153
- // }
150
+ err = v .deleteCurrentVirtualMachineBlockDeviceAttachments (ctx )
151
+ if err != nil {
152
+ return err
153
+ }
154
154
155
155
// Early return if VM is already fully processed by this restore operation
156
156
if value , ok := vm .Annotations [annotations .AnnVMRestore ]; ok && value == v .restoreUID {
@@ -262,9 +262,9 @@ func (v *VirtualMachineHandler) Object() client.Object {
262
262
return v .vm
263
263
}
264
264
265
- func (v * VirtualMachineHandler ) deleteCurrentVirtualMachineBlockDeviceAttachments (ctx context.Context , vmName , vmNamespace , vmRestoreUID string ) error {
265
+ func (v * VirtualMachineHandler ) deleteCurrentVirtualMachineBlockDeviceAttachments (ctx context.Context ) error {
266
266
vmbdas := & v1alpha2.VirtualMachineBlockDeviceAttachmentList {}
267
- err := v .client .List (ctx , vmbdas , & client.ListOptions {Namespace : vmNamespace })
267
+ err := v .client .List (ctx , vmbdas , & client.ListOptions {Namespace : v . vm . Namespace })
268
268
if err != nil {
269
269
return fmt .Errorf ("failed to list the `VirtualMachineBlockDeviceAttachment`: %w" , err )
270
270
}
@@ -277,7 +277,7 @@ func (v *VirtualMachineHandler) deleteCurrentVirtualMachineBlockDeviceAttachment
277
277
278
278
vmbdasToDelete := make ([]* v1alpha2.VirtualMachineBlockDeviceAttachment , 0 , len (vmbdas .Items ))
279
279
for _ , vmbda := range vmbdas .Items {
280
- if vmbda .Spec .VirtualMachineName != vmName {
280
+ if vmbda .Spec .VirtualMachineName != v . vm . Name {
281
281
continue
282
282
}
283
283
0 commit comments