Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Commit

Permalink
Fix race condition for concurrent predicate and priority in allocate
Browse files Browse the repository at this point in the history
  • Loading branch information
hex108 committed Apr 2, 2019
1 parent 4333226 commit b7c5377
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package allocate

import (
"context"
"sync"

"github.com/golang/glog"
"k8s.io/client-go/util/workqueue"
Expand Down Expand Up @@ -132,6 +133,7 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
job.NodesFitDelta = make(api.NodeResourceMap)
}

var workerLock sync.Mutex
checkNode := func(index int) {
node := allNodes[index]
glog.V(3).Infof("Considering Task <%v/%v> on node <%v>: <%v> vs. <%v>",
Expand All @@ -142,7 +144,9 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
glog.V(3).Infof("Predicates failed for task <%s/%s> on node <%s>: %v",
task.Namespace, task.Name, node.Name, err)
} else {
workerLock.Lock()
predicateNodes = append(predicateNodes, node)
workerLock.Unlock()
}
}
workqueue.ParallelizeUntil(context.TODO(), 16, len(allNodes), checkNode)
Expand All @@ -153,7 +157,9 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
if err != nil {
glog.V(3).Infof("Error in Calculating Priority for the node:%v", err)
} else {
workerLock.Lock()
nodeScores[score] = append(nodeScores[score], node)
workerLock.Unlock()
}
}
workqueue.ParallelizeUntil(context.TODO(), 16, len(predicateNodes), scoreNode)
Expand Down

0 comments on commit b7c5377

Please sign in to comment.