From 34524e8a689107e8c6f1bfb844457d2f70b2db83 Mon Sep 17 00:00:00 2001 From: Damien Grisonnet Date: Mon, 3 Aug 2026 09:06:46 +0200 Subject: [PATCH] cri: skip failed container instead of dropping entire sandbox metrics When collectContainerMetrics fails for a single container, the goroutine was returning nil which exited the loop entirely. The sandbox metrics, including pod-level network metrics and any successfully collected container metrics, were never appended to the response. Replace return nil with continue so that individual container failures only skip that container. Signed-off-by: Damien Grisonnet --- internal/cri/server/list_pod_sandbox_metrics_linux.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cri/server/list_pod_sandbox_metrics_linux.go b/internal/cri/server/list_pod_sandbox_metrics_linux.go index bdd5730af2..83f0cefb68 100644 --- a/internal/cri/server/list_pod_sandbox_metrics_linux.go +++ b/internal/cri/server/list_pod_sandbox_metrics_linux.go @@ -109,7 +109,7 @@ func (c *criService) ListPodSandboxMetrics(ctx context.Context, r *runtime.ListP case errdefs.IsUnavailable(err), errdefs.IsNotFound(err): log.G(gctx).WithField("podsandboxid", sandbox.ID).WithField("containerid", container.ID).WithError(err).Error("failed to get container metrics, this is likely a transient error") // Don't return error for transient issues, just log and continue - return nil + continue case errdefs.IsCanceled(err): log.G(gctx).WithField("podsandboxid", sandbox.ID).WithField("containerid", container.ID).WithError(err).Debug("metrics collection cancelled") // Return the cancellation error to stop other goroutines @@ -117,7 +117,7 @@ func (c *criService) ListPodSandboxMetrics(ctx context.Context, r *runtime.ListP default: log.G(gctx).WithField("podsandboxid", sandbox.ID).WithField("containerid", container.ID).WithError(err).Error("failed to collect container metrics") // Don't return error for individual failures, just log and continue - return nil + continue } }