add RPC timeout to maybeSchedRequest
This commit is contained in:
parent
d9de9b7cb4
commit
be4112ee68
6
sched.go
6
sched.go
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -214,7 +215,10 @@ func (sh *scheduler) maybeSchedRequest(req *workerRequest) (bool, error) {
|
|||||||
needRes := ResourceTable[req.taskType][sh.spt]
|
needRes := ResourceTable[req.taskType][sh.spt]
|
||||||
|
|
||||||
for wid, worker := range sh.workers {
|
for wid, worker := range sh.workers {
|
||||||
ok, err := req.sel.Ok(req.ctx, req.taskType, sh.spt, worker)
|
rpcCtx, cancel := context.WithTimeout(req.ctx, 5*time.Second)
|
||||||
|
ok, err := req.sel.Ok(rpcCtx, req.taskType, sh.spt, worker)
|
||||||
|
cancel()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user