From 2fa77a5eb1a9e0a1f315b40241314751de06c2ef Mon Sep 17 00:00:00 2001 From: "Fabio M. Graetz, Ph.D." Date: Tue, 5 Nov 2024 19:41:08 +0100 Subject: [PATCH] Fix: avoid log spam for log links generated during the pod's pending phase (#5945) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio Grätz Co-authored-by: Fabio Grätz --- flyteplugins/go/tasks/logs/logging_utils.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/flyteplugins/go/tasks/logs/logging_utils.go b/flyteplugins/go/tasks/logs/logging_utils.go index 3322cc37d8..4bfff0dd17 100644 --- a/flyteplugins/go/tasks/logs/logging_utils.go +++ b/flyteplugins/go/tasks/logs/logging_utils.go @@ -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 }