Add functional test to verify target pod is cleaned up shortly after migration fails
@@ -1524,6 +1524,46 @@ var _ = Describe("[Serial][rfe_id:393][crit:high][vendor:cnv-qe@redhat.com][leve
By("Waiting for VMI to disappear")
tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 240)
})
+
+ It("Target pod should exit after failed migration", func() {
+ vmi := tests.NewRandomFedoraVMIWithGuestAgent()
+ vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("1Gi")
+
+ // this annotation causes virt launcher to immediately fail a migration
+ vmi.Annotations = map[string]string{v1.FuncTestForceLauncherMigrationFailureAnnotation: ""}
+
+ By("Starting the VirtualMachineInstance")
+ vmi = runVMIAndExpectLaunch(vmi, 240)
+
+ // execute a migration, wait for finalized state
+ By("Starting the Migration")
+ migration := tests.NewRandomMigration(vmi.Name, vmi.Namespace)
+ migrationUID := runMigrationAndExpectFailure(migration, 180)
+
+ // check VMI, confirm migration state
+ confirmVMIPostMigrationFailed(vmi, migrationUID)
+
+ Eventually(func() error {
+ vmi, err = virtClient.VirtualMachineInstance(vmi.Namespace).Get(vmi.Name, &metav1.GetOptions{})
+ Expect(err).ToNot(HaveOccurred())
+
+ pod, err := virtClient.CoreV1().Pods(vmi.Namespace).Get(context.Background(), vmi.Status.MigrationState.TargetPod, metav1.GetOptions{})
+ Expect(err).ToNot(HaveOccurred())
+
+ if pod.Status.Phase == k8sv1.PodFailed || pod.Status.Phase == k8sv1.PodSucceeded {
+ return nil
+ }
+
+ return fmt.Errorf("still waiting on target pod to complete, current phase is %s", pod.Status.Phase)
+ }, 10*time.Second, time.Second).Should(Succeed(), "Target pod should exit quickly after migration fails.")
+
+ // delete VMI
+ By("Deleting the VMI")
+ Expect(virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})).To(Succeed())
+
+ By("Waiting for VMI to disappear")
+ tests.WaitForVirtualMachineToDisappearWithTimeout(vmi, 240)
+ })
})
Context("with an Cirros non-shared ISCSI PVC (using ISCSI IPv4 address)", func() {
var pvName string
