Skip to content

Commit

Permalink
Fix: avoid log spam for log links generated during the pod's pending …
Browse files Browse the repository at this point in the history
…phase (flyteorg#5945)

Signed-off-by: Fabio Grätz <[email protected]>
Co-authored-by: Fabio Grätz <[email protected]>
  • Loading branch information
fg91 and Fabio Grätz authored Nov 5, 2024
1 parent ab67b4e commit 2fa77a5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flyteplugins/go/tasks/logs/logging_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ func GetLogsForContainerInPod(ctx context.Context, logPlugin tasklog.Plugin, tas

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)
msg := fmt.Sprintf("containerStatus IndexOutOfBound, requested [%d], but total containerStatuses [%d] in pod phase [%v]", index, len(pod.Status.ContainerStatuses), pod.Status.Phase)
if pod.Status.Phase == v1.PodPending {
// If the pod is pending, the container status may not be available yet. Log as debug.
logger.Debugf(ctx, msg)
} else {
// In other phases, this is unexpected. Log as error.
logger.Errorf(ctx, msg)
}
} else {
containerID = pod.Status.ContainerStatuses[index].ContainerID
}
Expand Down

0 comments on commit 2fa77a5

Please sign in to comment.