From 634786f8f49230a5397f1f22d9ab7cd2cfaf581f Mon Sep 17 00:00:00 2001 From: Fabio Graetz Date: Sun, 14 Jan 2024 18:39:18 +0000 Subject: [PATCH] Fix nil containerId in pending phase Signed-off-by: Fabio Graetz --- flyteplugins/go/tasks/logs/logging_utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flyteplugins/go/tasks/logs/logging_utils.go b/flyteplugins/go/tasks/logs/logging_utils.go index 20f3522e27b..5d2db04ab66 100644 --- a/flyteplugins/go/tasks/logs/logging_utils.go +++ b/flyteplugins/go/tasks/logs/logging_utils.go @@ -29,9 +29,12 @@ func GetLogsForContainerInPod(ctx context.Context, logPlugin tasklog.Plugin, tas return nil, nil } + containerID := v1.ContainerStatus{}.ContainerID if uint32(len(pod.Status.ContainerStatuses)) <= index { logger.Errorf(ctx, "containerStatus IndexOutOfBound, requested [%d], but total containerStatuses [%d] in pod phase [%v]", index, len(pod.Status.ContainerStatuses), pod.Status.Phase) - return nil, nil + // return nil, nil + } else { + containerID = pod.Status.ContainerStatuses[index].ContainerID } startTime := pod.CreationTimestamp.Unix() @@ -43,7 +46,7 @@ func GetLogsForContainerInPod(ctx context.Context, logPlugin tasklog.Plugin, tas PodUID: string(pod.GetUID()), Namespace: pod.Namespace, ContainerName: pod.Spec.Containers[index].Name, - ContainerID: pod.Status.ContainerStatuses[index].ContainerID, + ContainerID: containerID, LogName: nameSuffix, PodRFC3339StartTime: time.Unix(startTime, 0).Format(time.RFC3339), PodRFC3339FinishTime: time.Unix(finishTime, 0).Format(time.RFC3339),