Skip to content

Commit

Permalink
Fix nil containerId in pending phase
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Graetz <[email protected]>
  • Loading branch information
fg91 committed Jan 14, 2024
1 parent a08bd5b commit 634786f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flyteplugins/go/tasks/logs/logging_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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),
Expand Down

0 comments on commit 634786f

Please sign in to comment.