From a48dbefc151f86fa382446014c41ea34308f743c Mon Sep 17 00:00:00 2001 From: Daniel Lenar Date: Fri, 17 Feb 2023 15:10:54 -0600 Subject: [PATCH] Fix concurrent writes for UpdateContainerStats Signed-off-by: Daniel Lenar --- pkg/cri/store/sandbox/sandbox.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cri/store/sandbox/sandbox.go b/pkg/cri/store/sandbox/sandbox.go index 35e4603a2..26dd8f6db 100644 --- a/pkg/cri/store/sandbox/sandbox.go +++ b/pkg/cri/store/sandbox/sandbox.go @@ -129,8 +129,8 @@ func (s *Store) List() []Sandbox { // stats present in 'newContainerStats'. Returns errdefs.ErrNotFound // if the sandbox does not exist in the store. func (s *Store) UpdateContainerStats(id string, newContainerStats *stats.ContainerStats) error { - s.lock.RLock() - defer s.lock.RUnlock() + s.lock.Lock() + defer s.lock.Unlock() id, err := s.idIndex.Get(id) if err != nil { if err == truncindex.ErrNotExist {