Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func getMessageByMigrationFailedReason(mig *virtv1.VirtualMachineInstanceMigrati
case virtv1.VirtualMachineInstanceMigrationFailedReasonVMIDoesNotExist, virtv1.VirtualMachineInstanceMigrationFailedReasonVMIIsShutdown:
return "VirtualMachine is stopped"
default:
return cond.Message
return humanizeMigrationFailedMessage(cond.Message)
}
}

Expand Down Expand Up @@ -678,6 +678,14 @@ func (h LifecycleHandler) forgetProgress(vmop *v1alpha2.VirtualMachineOperation)
h.progressStrategy.Forget(vmop.UID)
}

func humanizeMigrationFailedMessage(message string) string {
if strings.Contains(message, "unschedulable target pod") && strings.Contains(message, "timeout period expiration") {
return "No available nodes were found to place the target VM within the timeout period"
}

return message
}

func (h LifecycleHandler) getTargetPod(ctx context.Context, mig *virtv1.VirtualMachineInstanceMigration) (*corev1.Pod, error) {
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,4 +902,31 @@ var _ = Describe("LifecycleHandler", func() {
Expect(reason).To(Equal(vmopcondition.ReasonTargetPreparing))
})
})

DescribeTable("humanizeMigrationFailedMessage", func(message, expected string) {
Expect(humanizeMigrationFailedMessage(message)).To(Equal(expected))
},
Entry(
"should humanize unschedulable target pod timeout message",
"unschedulable target pod \"virt-launcher-bastion-demo-z7hcs\" was deleted due to timeout period expiration",
"No available nodes were found to place the target VM within the timeout period",
),
Entry(
"should keep other messages as is",
"some other migration failure",
"some other migration failure",
),
)

It("should use humanized message for migration failed condition", func() {
mig := newSimpleMigration("test", name)
mig.Status.Conditions = []virtv1.VirtualMachineInstanceMigrationCondition{{
Type: virtv1.VirtualMachineInstanceMigrationFailed,
Status: corev1.ConditionTrue,
Reason: "SomeOtherReason",
Message: "unschedulable target pod \"virt-launcher-bastion-demo-z7hcs\" was deleted due to timeout period expiration",
}}

Expect(getMessageByMigrationFailedReason(mig)).To(Equal("No available nodes were found to place the target VM within the timeout period"))
})
})
Loading