sched: Fix error handling in assignWorker
This commit is contained in:
parent
d399312786
commit
d57877af31
22
sched.go
22
sched.go
@ -247,8 +247,28 @@ func (sh *scheduler) assignWorker(wid WorkerID, w *workerHandle, req *workerRequ
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err := req.prepare(req.ctx, w.w)
|
err := req.prepare(req.ctx, w.w)
|
||||||
|
|
||||||
sh.workersLk.Lock()
|
sh.workersLk.Lock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
w.preparing.free(w.info.Resources, needRes)
|
||||||
|
sh.workersLk.Unlock()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case sh.workerFree <- wid:
|
||||||
|
case <-sh.closing:
|
||||||
|
log.Warnf("scheduler closed while sending response (prepare error: %+v)", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case req.ret <- workerResponse{err: err}:
|
||||||
|
case <-req.ctx.Done():
|
||||||
|
log.Warnf("request got cancelled before we could respond (prepare error: %+v)", err)
|
||||||
|
case <-sh.closing:
|
||||||
|
log.Warnf("scheduler closed while sending response (prepare error: %+v)", err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = w.active.withResources(sh.spt, wid, w.info.Resources, needRes, &sh.workersLk, func() error {
|
err = w.active.withResources(sh.spt, wid, w.info.Resources, needRes, &sh.workersLk, func() error {
|
||||||
w.preparing.free(w.info.Resources, needRes)
|
w.preparing.free(w.info.Resources, needRes)
|
||||||
sh.workersLk.Unlock()
|
sh.workersLk.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user