From 2e174a029f5021f9eaae78286c4ce2ce4f56f452 Mon Sep 17 00:00:00 2001 From: Harshal Patil Date: Wed, 30 Aug 2023 10:18:33 -0400 Subject: [PATCH] Add timeout to listContainerStats context Signed-off-by: Harshal Patil --- pkg/kubelet/cri/remote/remote_runtime.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/kubelet/cri/remote/remote_runtime.go b/pkg/kubelet/cri/remote/remote_runtime.go index 64571069376..36b3839eb74 100644 --- a/pkg/kubelet/cri/remote/remote_runtime.go +++ b/pkg/kubelet/cri/remote/remote_runtime.go @@ -674,9 +674,7 @@ func (r *remoteRuntimeService) containerStatsV1(ctx context.Context, containerID // ListContainerStats returns the list of ContainerStats given the filter. func (r *remoteRuntimeService) ListContainerStats(ctx context.Context, filter *runtimeapi.ContainerStatsFilter) ([]*runtimeapi.ContainerStats, error) { klog.V(10).InfoS("[RemoteRuntimeService] ListContainerStats", "filter", filter) - // Do not set timeout, because writable layer stats collection takes time. - // TODO(random-liu): Should we assume runtime should cache the result, and set timeout here? - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithTimeout(ctx, r.timeout) defer cancel() return r.listContainerStatsV1(ctx, filter)