From 51dac1b7e6488b129cc37c46f717f7a699167eb9 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:00:14 -0500 Subject: [PATCH 1/3] fix(e2e): read VMB backup type from status.includedVolumes[].type KubeVirt dropped VirtualMachineBackup.status.type (kubevirt/kubevirt f1a69f53c) in favour of per-volume status.includedVolumes[].type, so GetVMBBackupType never saw a type on current KubeVirt and timed out in the virt-kdm incremental sequence test. Derive the type from the included volumes: Incremental only if every volume is incremental, otherwise Full. This keeps the test checking the backup type virt-controller actually performed rather than the controller's own expected-backup-type annotation. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> --- tests/e2e/lib/virt_helpers.go | 33 +++++++++++++++------ tests/e2e/virt_backup_restore_suite_test.go | 8 ++--- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/tests/e2e/lib/virt_helpers.go b/tests/e2e/lib/virt_helpers.go index 5715272e6be..baf692805cd 100644 --- a/tests/e2e/lib/virt_helpers.go +++ b/tests/e2e/lib/virt_helpers.go @@ -129,8 +129,8 @@ var virtualMachineBackupTrackerGvr = schema.GroupVersionResource{ // virtualMachineBackupGvr is the per-backup VirtualMachineBackup (VMB) resource — distinct // from VirtualMachineBackupTracker (VMBT, tracked via virtualMachineBackupTrackerGvr above), -// which persists checkpoint state across backups. VMB.Status.Type reports "full" or -// "incremental" for a single completed backup. +// which persists checkpoint state across backups. VMB status.includedVolumes[].type reports "Full" or "Incremental" +// for a single completed backup. var virtualMachineBackupGvr = schema.GroupVersionResource{ Group: "backup.kubevirt.io", Resource: "virtualmachinebackups", @@ -1662,8 +1662,13 @@ func (v *VirtOperator) CheckVMBackupTrackerExists(namespace string) (bool, error } // GetVMBBackupType finds the VirtualMachineBackup in namespace whose -// annotationDataUploadName annotation matches dataUploadName, and returns its -// status.type ("full"/"incremental") and status.checkpointName. +// annotationDataUploadName annotation matches dataUploadName, and returns the +// backup type ("Full"/"Incremental") derived from status.includedVolumes[].type +// plus status.checkpointName. +// +// KubeVirt dropped the whole-backup status.type field in favour of the +// per-volume type, so the backup is "Incremental" only if every included +// volume is incremental, and "Full" if any volume was backed up in full. func (v *VirtOperator) GetVMBBackupType(namespace, dataUploadName string) (backupType, checkpointName string, err error) { list, err := v.Dynamic.Resource(virtualMachineBackupGvr).Namespace(namespace).List(context.Background(), metav1.ListOptions{}) if err != nil { @@ -1673,13 +1678,23 @@ func (v *VirtOperator) GetVMBBackupType(namespace, dataUploadName string) (backu if vmb.GetAnnotations()[annotationDataUploadName] != dataUploadName { continue } - found := false - backupType, found, err = unstructured.NestedString(vmb.Object, "status", "type") + volumes, found, err := unstructured.NestedSlice(vmb.Object, "status", "includedVolumes") if err != nil { - return "", "", fmt.Errorf("failed to read status.type from VirtualMachineBackup %s/%s: %w", namespace, vmb.GetName(), err) + return "", "", fmt.Errorf("failed to read status.includedVolumes from VirtualMachineBackup %s/%s: %w", namespace, vmb.GetName(), err) + } + if !found || len(volumes) == 0 { + return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has no status.includedVolumes yet", namespace, vmb.GetName()) } - if !found { - return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has no status.type yet", namespace, vmb.GetName()) + backupType = "Incremental" + for _, vol := range volumes { + volMap, _ := vol.(map[string]interface{}) + volType, _ := volMap["type"].(string) + if volType == "" { + return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with no type yet", namespace, vmb.GetName()) + } + if !strings.EqualFold(volType, "Incremental") { + backupType = "Full" + } } foundCheckpoint := false checkpointName, foundCheckpoint, err = unstructured.NestedString(vmb.Object, "status", "checkpointName") diff --git a/tests/e2e/virt_backup_restore_suite_test.go b/tests/e2e/virt_backup_restore_suite_test.go index ff16f2027de..64da3dd0af0 100644 --- a/tests/e2e/virt_backup_restore_suite_test.go +++ b/tests/e2e/virt_backup_restore_suite_test.go @@ -934,13 +934,13 @@ var _ = ginkgo.Describe("VM backup and restore tests", ginkgo.Ordered, func() { actualBackupType, _, err = v.GetVMBBackupType(incSeqNamespace, dataUploadName) return err }, 5*time.Minute, time.Second*5).Should(gomega.Succeed(), "failed to get VirtualMachineBackup status for DataUpload %s", dataUploadName) - // VirtualMachineBackup.status.type is PascalCase (virt-controller's own + // VirtualMachineBackup status.includedVolumes[].type is PascalCase (virt-controller's own // convention, e.g. "Full"/"Incremental"), while the DataUpload's // expected-backup-type annotation is lowercase (kubevirt-datamover-controller's // convention, e.g. "full"/"incremental") -- normalize case before comparing // these two independently-maintained values. actualBackupType = strings.ToLower(actualBackupType) - gomega.Expect(actualBackupType).To(gomega.Equal(expectedType), "actual VirtualMachineBackup.Status.Type") + gomega.Expect(actualBackupType).To(gomega.Equal(expectedType), "actual VirtualMachineBackup backup type (status.includedVolumes[].type)") gomega.Expect(actualBackupType).To(gomega.Equal(strings.ToLower(expectedBackupType)), "expected vs. actual backup type must not mismatch") }) } @@ -1066,7 +1066,7 @@ var _ = ginkgo.Describe("VM backup and restore tests", ginkgo.Ordered, func() { // verifyBackupType returns a runKubevirtDMBackup callback that hard-asserts // both the DataUpload's expected-backup-type annotation and the - // VirtualMachineBackup's actual Status.Type match expectedType -- mirrors + // VirtualMachineBackup's actual backup type (status.includedVolumes[].type) match expectedType -- mirrors // the check already done inline in runSequenceBackup above, factored out // since the incremental-restore test below needs the same check twice // (full, then incremental) and getting this wrong would silently @@ -1083,7 +1083,7 @@ var _ = ginkgo.Describe("VM backup and restore tests", ginkgo.Ordered, func() { return err }, 5*time.Minute, time.Second*5).Should(gomega.Succeed(), "failed to get VirtualMachineBackup status for DataUpload %s", dataUploadName) actualBackupType = strings.ToLower(actualBackupType) - gomega.Expect(actualBackupType).To(gomega.Equal(expectedType), "actual VirtualMachineBackup.Status.Type for DataUpload %s", dataUploadName) + gomega.Expect(actualBackupType).To(gomega.Equal(expectedType), "actual VirtualMachineBackup backup type (status.includedVolumes[].type) for DataUpload %s", dataUploadName) } } From a77cc3c710234a8241d489dc89980ee7943dfe54 Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:05:53 -0500 Subject: [PATCH 2/3] fix(e2e): reject unknown VMB included-volume types Only Full and Incremental are valid; treating any other value as Full could let a full-backup assertion pass without evidence of a full backup. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> --- tests/e2e/lib/virt_helpers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/e2e/lib/virt_helpers.go b/tests/e2e/lib/virt_helpers.go index baf692805cd..1692b19feba 100644 --- a/tests/e2e/lib/virt_helpers.go +++ b/tests/e2e/lib/virt_helpers.go @@ -1692,8 +1692,12 @@ func (v *VirtOperator) GetVMBBackupType(namespace, dataUploadName string) (backu if volType == "" { return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with no type yet", namespace, vmb.GetName()) } - if !strings.EqualFold(volType, "Incremental") { + switch { + case strings.EqualFold(volType, "Incremental"): + case strings.EqualFold(volType, "Full"): backupType = "Full" + default: + return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with unknown type %q", namespace, vmb.GetName(), volType) } } foundCheckpoint := false From 0f9ac65fc92eb16b295859fb361ce9b9cae60b7b Mon Sep 17 00:00:00 2001 From: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:29:17 -0500 Subject: [PATCH 3/3] fix(e2e): treat mixed-type VMBs as incremental, matching the controller kubevirt-datamover-controller records one type per checkpoint and keeps a mixed backup (some volumes full, some incremental) incremental so the parent chain is preserved. Mirror that in GetVMBBackupType. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Tiger Kaovilai <11228024+kaovilai@users.noreply.github.com> --- tests/e2e/lib/virt_helpers.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/e2e/lib/virt_helpers.go b/tests/e2e/lib/virt_helpers.go index 1692b19feba..1aa390213a9 100644 --- a/tests/e2e/lib/virt_helpers.go +++ b/tests/e2e/lib/virt_helpers.go @@ -1667,8 +1667,10 @@ func (v *VirtOperator) CheckVMBackupTrackerExists(namespace string) (bool, error // plus status.checkpointName. // // KubeVirt dropped the whole-backup status.type field in favour of the -// per-volume type, so the backup is "Incremental" only if every included -// volume is incremental, and "Full" if any volume was backed up in full. +// per-volume type. This mirrors kubevirt-datamover-controller, which records +// one type per checkpoint: "Incremental" if any included volume is incremental +// (so the checkpoint's parent chain is preserved), "Full" only if every volume +// is full. func (v *VirtOperator) GetVMBBackupType(namespace, dataUploadName string) (backupType, checkpointName string, err error) { list, err := v.Dynamic.Resource(virtualMachineBackupGvr).Namespace(namespace).List(context.Background(), metav1.ListOptions{}) if err != nil { @@ -1685,17 +1687,16 @@ func (v *VirtOperator) GetVMBBackupType(namespace, dataUploadName string) (backu if !found || len(volumes) == 0 { return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has no status.includedVolumes yet", namespace, vmb.GetName()) } - backupType = "Incremental" + backupType = "Full" for _, vol := range volumes { volMap, _ := vol.(map[string]interface{}) volType, _ := volMap["type"].(string) - if volType == "" { - return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with no type yet", namespace, vmb.GetName()) - } switch { + case volType == "": + return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with no type yet", namespace, vmb.GetName()) case strings.EqualFold(volType, "Incremental"): + backupType = "Incremental" case strings.EqualFold(volType, "Full"): - backupType = "Full" default: return "", "", fmt.Errorf("VirtualMachineBackup %s/%s has an included volume with unknown type %q", namespace, vmb.GetName(), volType) }