Skip to content

Commit

Permalink
Fix race condition if store result map
Browse files Browse the repository at this point in the history
* Add mutexes to every read/write access the store makes
  to the results map
  • Loading branch information
Ezetowers committed Feb 11, 2022
1 parent 17382c9 commit 0aeb8f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scheduler/plugin/resultstore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func newData() *result {
}

func (s *Store) addSchedulingResultToPod(_, newObj interface{}) {
s.mu.Lock()
defer s.mu.Unlock()
ctx := context.Background()

pod, ok := newObj.(*v1.Pod)
Expand Down Expand Up @@ -233,5 +235,7 @@ func (s *Store) applyWeightOnScore(pluginName string, score int64) int64 {
}

func (s *Store) DeleteData(k key) {
s.mu.Lock()
defer s.mu.Unlock()
delete(s.results, k)
}

0 comments on commit 0aeb8f2

Please sign in to comment.