@@ -222,6 +222,9 @@ func getVolumeNameToVmMap(client k8sclient.Client, namespace string) (map[string
222
222
vmList := virtv1.VirtualMachineList {}
223
223
err := client .List (context .TODO (), & vmList , k8sclient .InNamespace (namespace ))
224
224
if err != nil {
225
+ if meta .IsNoMatchError (err ) {
226
+ return nil , nil
227
+ }
225
228
return nil , err
226
229
}
227
230
for _ , vm := range vmList .Items {
@@ -244,6 +247,9 @@ func (t *Task) storageLiveMigrateVM(vmName, namespace string, volumes *vmVolumes
244
247
}
245
248
vm := & virtv1.VirtualMachine {}
246
249
if err := sourceClient .Get (context .TODO (), k8sclient.ObjectKey {Namespace : namespace , Name : vmName }, vm ); err != nil {
250
+ if meta .IsNoMatchError (err ) {
251
+ return nil
252
+ }
247
253
return err
248
254
}
249
255
// Check if the source volumes match before attempting to migrate.
@@ -312,6 +318,9 @@ func (t *Task) verifyVMs() error {
312
318
vm := & virtv1.VirtualMachine {}
313
319
err := sourceClient .Get (context .TODO (), k8sclient.ObjectKey {Namespace : namespace , Name : vmName }, vm )
314
320
if err != nil {
321
+ if meta .IsNoMatchError (err ) {
322
+ return nil
323
+ }
315
324
t .Log .Info ("Failed to get running VM" , "err" , err )
316
325
return liberr .Wrap (FatalPlanError , err .Error ())
317
326
}
@@ -335,6 +344,9 @@ func (t *Task) verifyVMs() error {
335
344
func findVirtualMachineInstanceMigration (client k8sclient.Client , vmName , namespace string ) (* virtv1.VirtualMachineInstanceMigration , error ) {
336
345
vmimList := & virtv1.VirtualMachineInstanceMigrationList {}
337
346
if err := client .List (context .TODO (), vmimList , k8sclient .InNamespace (namespace )); err != nil {
347
+ if meta .IsNoMatchError (err ) {
348
+ return nil , nil
349
+ }
338
350
if k8serrors .IsNotFound (err ) {
339
351
return nil , nil
340
352
}
@@ -401,6 +413,9 @@ func virtualMachineMigrationStatus(client k8sclient.Client, vmName, namespace st
401
413
func cancelLiveMigration (client k8sclient.Client , vmName , namespace string , volumes * vmVolumes , log logr.Logger ) error {
402
414
vm := & virtv1.VirtualMachine {}
403
415
if err := client .Get (context .TODO (), k8sclient.ObjectKey {Namespace : namespace , Name : vmName }, vm ); err != nil {
416
+ if meta .IsNoMatchError (err ) {
417
+ return nil
418
+ }
404
419
return err
405
420
}
406
421
@@ -414,6 +429,9 @@ func cancelLiveMigration(client k8sclient.Client, vmName, namespace string, volu
414
429
func liveMigrationsCompleted (client k8sclient.Client , namespace string , vmNames []string ) (bool , error ) {
415
430
vmim := & virtv1.VirtualMachineInstanceMigrationList {}
416
431
if err := client .List (context .TODO (), vmim , k8sclient .InNamespace (namespace )); err != nil {
432
+ if meta .IsNoMatchError (err ) {
433
+ return true , nil
434
+ }
417
435
return false , err
418
436
}
419
437
completed := true
@@ -569,6 +587,9 @@ func (t *Task) getVolumeVMIMInNamespaces(namespaces []string) (map[string]*virtv
569
587
for volumeName , vmName := range volumeVMMap {
570
588
vmimList := & virtv1.VirtualMachineInstanceMigrationList {}
571
589
if err := t .sourceClient .List (context .TODO (), vmimList , k8sclient .InNamespace (namespace )); err != nil {
590
+ if meta .IsNoMatchError (err ) {
591
+ return nil , nil
592
+ }
572
593
return nil , err
573
594
}
574
595
for _ , vmim := range vmimList .Items {
0 commit comments