Skip to content

Commit c478cf2

Browse files
committed
fix(api, vmop): fix getTargetPodDiskError to check Pending pod directly
kubelet emits FailedAttachVolume/FailedMount events while pod is in Pending phase — before ContainerCreating state is ever reached. The previous ContainerCreating guard prevented detection entirely. Now check events for any Pending pod that is not being deleted. Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent fed7237 commit c478cf2

1 file changed

Lines changed: 14 additions & 25 deletions

File tree

  • images/virtualization-artifact/pkg/controller/vmop/migration/internal/handler

images/virtualization-artifact/pkg/controller/vmop/migration/internal/handler/lifecycle.go

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -649,37 +649,26 @@ func (h LifecycleHandler) calculateMigrationProgress(
649649
}
650650

651651
func (h LifecycleHandler) getTargetPodDiskError(ctx context.Context, pod *corev1.Pod) (string, bool) {
652-
if pod == nil {
652+
if pod == nil || pod.Status.Phase != corev1.PodPending || pod.DeletionTimestamp != nil {
653653
return "", false
654654
}
655655

656-
for _, cs := range pod.Status.InitContainerStatuses {
657-
if cs.State.Waiting != nil && cs.State.Waiting.Reason == "ContainerCreating" {
658-
break
659-
}
656+
eventList := &corev1.EventList{}
657+
err := h.client.List(ctx, eventList, &client.ListOptions{
658+
Namespace: pod.Namespace,
659+
FieldSelector: fields.SelectorFromSet(fields.Set{
660+
"involvedObject.name": pod.Name,
661+
"involvedObject.kind": "Pod",
662+
}),
663+
})
664+
if err != nil {
665+
return "", false
660666
}
661-
for _, cs := range pod.Status.ContainerStatuses {
662-
if cs.State.Waiting != nil && cs.State.Waiting.Reason == "ContainerCreating" {
663-
eventList := &corev1.EventList{}
664-
err := h.client.List(ctx, eventList, &client.ListOptions{
665-
Namespace: pod.Namespace,
666-
FieldSelector: fields.SelectorFromSet(fields.Set{
667-
"involvedObject.name": pod.Name,
668-
"involvedObject.kind": "Pod",
669-
}),
670-
})
671-
if err != nil {
672-
return "", false
673-
}
674-
for _, e := range eventList.Items {
675-
if e.Type == corev1.EventTypeWarning && (e.Reason == reasonFailedAttachVolume || e.Reason == reasonFailedMount) {
676-
return fmt.Sprintf("%s: %s", e.Reason, e.Message), true
677-
}
678-
}
679-
return "", false
667+
for _, e := range eventList.Items {
668+
if e.Type == corev1.EventTypeWarning && (e.Reason == reasonFailedAttachVolume || e.Reason == reasonFailedMount) {
669+
return fmt.Sprintf("%s: %s", e.Reason, e.Message), true
680670
}
681671
}
682-
683672
return "", false
684673
}
685674

0 commit comments

Comments
 (0)