From 6765524b73beac359ca43520faaf74347d94b6b5 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 11 Nov 2021 15:17:48 +0000 Subject: [PATCH] use write lock when updating container stats Signed-off-by: Michael Crosby --- pkg/cri/store/container/container.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/cri/store/container/container.go b/pkg/cri/store/container/container.go index dd584bc5a..b0b5985a5 100644 --- a/pkg/cri/store/container/container.go +++ b/pkg/cri/store/container/container.go @@ -170,8 +170,8 @@ func (s *Store) List() []Container { } 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 {