sched: Try scheduling on newly connected workers

This commit is contained in:
Łukasz Magiera 2020-05-01 17:29:27 +02:00
parent 83b1b94034
commit 1da6937a0f

View File

@ -131,7 +131,9 @@ func (sh *scheduler) runSched() {
for { for {
select { select {
case w := <-sh.newWorkers: case w := <-sh.newWorkers:
sh.schedNewWorker(w) wid := sh.schedNewWorker(w)
sh.onWorkerFreed(wid)
case req := <-sh.schedule: case req := <-sh.schedule:
scheduled, err := sh.maybeSchedRequest(req) scheduled, err := sh.maybeSchedRequest(req)
if err != nil { if err != nil {
@ -409,13 +411,15 @@ func (a *activeResources) utilization(wr storiface.WorkerResources) float64 {
return max return max
} }
func (sh *scheduler) schedNewWorker(w *workerHandle) { func (sh *scheduler) schedNewWorker(w *workerHandle) WorkerID {
sh.workersLk.Lock() sh.workersLk.Lock()
defer sh.workersLk.Unlock() defer sh.workersLk.Unlock()
id := sh.nextWorker id := sh.nextWorker
sh.workers[id] = w sh.workers[id] = w
sh.nextWorker++ sh.nextWorker++
return id
} }
func (sh *scheduler) schedClose() { func (sh *scheduler) schedClose() {