Fix concurrent writes for UpdateContainerStats

Signed-off-by: Daniel Lenar <dlenar@vailsys.com>
This commit is contained in:
Daniel Lenar 2023-02-17 15:10:54 -06:00
parent dc03a4baa2
commit a48dbefc15

View File

@ -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 {