Skip to content

Commit 00da259

Browse files
committed
Don't error out if VMI is not found, instead
report not found and handle that appropriately. Signed-off-by: Alexander Wels <awels@redhat.com>
1 parent 8cbfe85 commit 00da259

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

pkg/controller/directvolumemigration/rsync.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,9 @@ func (t *Task) updateVolumeLiveMigrationProgressStatus(volumeName, namespace str
17041704
return err
17051705
}
17061706
liveMigrationProgress.VMName = vmName
1707+
if message == vmiNotFound {
1708+
return nil
1709+
}
17071710
if message != "" {
17081711
vmMatchString := fmt.Sprintf("%s/%s", namespace, vmName)
17091712
liveMigrationProgress.Message = message

pkg/controller/directvolumemigration/vm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const (
4444
virtLauncherPodLabelSelectorValue = "virt-launcher"
4545
defaultVirtStorageClass = "storageclass.kubevirt.io/is-default-virt-class"
4646
defaultK8sStorageClass = "storageclass.kubernetes.io/is-default-class"
47+
vmiNotFound = "not found"
4748
)
4849

4950
var (
@@ -438,7 +439,7 @@ func virtualMachineMigrationStatus(client k8sclient.Client, vmName, namespace st
438439
if !k8serrors.IsNotFound(err) {
439440
return err.Error(), err
440441
}
441-
return fmt.Sprintf("VMI %s not found in namespace %s", vmName, namespace), err
442+
return vmiNotFound, nil
442443
}
443444
volumeChange := false
444445
liveMigrateable := false

pkg/controller/directvolumemigration/vm_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,14 @@ func TestVirtualMachineMigrationStatus(t *testing.T) {
445445
{
446446
name: "In progress VMIM",
447447
client: getFakeClientWithObjs(createInProgressVirtualMachineMigration("vmim", testNamespace, "vm")),
448-
expectedStatus: fmt.Sprintf("VMI %s not found in namespace %s", "vm", testNamespace),
449-
wantErr: true,
448+
expectedStatus: vmiNotFound,
449+
wantErr: false,
450450
},
451451
{
452452
name: "No VMIM or VMI",
453453
client: getFakeClientWithObjs(),
454-
expectedStatus: fmt.Sprintf("VMI %s not found in namespace %s", "vm", testNamespace),
455-
wantErr: true,
454+
expectedStatus: vmiNotFound,
455+
wantErr: false,
456456
},
457457
{
458458
name: "Failed VMIM with message",

0 commit comments

Comments
 (0)