@@ -830,5 +830,46 @@ var _ = Describe("LifecycleHandler", func() {
830830 Expect (err ).NotTo (HaveOccurred ())
831831 Expect (reason ).To (Equal (vmopcondition .ReasonTargetDiskError ))
832832 })
833+
834+ It ("should ignore target pod disk attach error when pod is not in ContainerCreating" , func () {
835+ mig := newSimpleMigration ("vmop-test" , name )
836+ mig .UID = "migration-uid"
837+ mig .Status .Phase = virtv1 .MigrationPreparingTarget
838+
839+ pod := & corev1.Pod {
840+ ObjectMeta : metav1.ObjectMeta {
841+ Namespace : namespace ,
842+ Name : "target-pod" ,
843+ Labels : map [string ]string {
844+ virtv1 .AppLabel : "virt-launcher" ,
845+ virtv1 .MigrationJobLabel : "migration-uid" ,
846+ },
847+ },
848+ Status : corev1.PodStatus {
849+ Phase : corev1 .PodPending ,
850+ ContainerStatuses : []corev1.ContainerStatus {
851+ {
852+ Name : "compute" ,
853+ State : corev1.ContainerState {Waiting : & corev1.ContainerStateWaiting {Reason : "ImagePullBackOff" }},
854+ },
855+ },
856+ },
857+ }
858+ event := & corev1.Event {
859+ ObjectMeta : metav1.ObjectMeta {Namespace : namespace , Name : "disk-event" },
860+ InvolvedObject : corev1.ObjectReference {Name : "target-pod" , Kind : "Pod" , Namespace : namespace },
861+ Type : corev1 .EventTypeWarning ,
862+ Reason : "FailedAttachVolume" ,
863+ Message : "failed to attach disk" ,
864+ }
865+
866+ fakeClient , err := testutil .NewFakeClientWithObjects (mig , pod , event )
867+ Expect (err ).NotTo (HaveOccurred ())
868+
869+ h := LifecycleHandler {client : fakeClient }
870+ reason , _ , err := h .getInProgressReasonAndMessage (ctx , mig )
871+ Expect (err ).NotTo (HaveOccurred ())
872+ Expect (reason ).To (Equal (vmopcondition .ReasonTargetPreparing ))
873+ })
833874 })
834875})
0 commit comments