mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
WatchCtx propogates context error
This commit is contained in:
@@ -149,7 +149,7 @@ func (w *Watcher) watchDeployments(ctx context.Context) {
|
||||
// Block getting all deployments using the last deployment index.
|
||||
deployments, idx, err := w.getDeploys(ctx, dindex)
|
||||
if err != nil {
|
||||
if err == context.Canceled || ctx.Err() == context.Canceled {
|
||||
if err == context.Canceled {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -179,9 +179,6 @@ func (w *Watcher) getDeploys(ctx context.Context, minIndex uint64) ([]*structs.D
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
return resp.([]*structs.Deployment), index, nil
|
||||
}
|
||||
|
||||
@@ -342,7 +342,6 @@ type blockingOptions struct {
|
||||
// blockingRPC is used for queries that need to wait for a
|
||||
// minimum index. This is used to block and wait for changes.
|
||||
func (s *Server) blockingRPC(opts *blockingOptions) error {
|
||||
var deadline time.Time
|
||||
ctx := context.Background()
|
||||
var cancel context.CancelFunc
|
||||
var state *state.StateStore
|
||||
@@ -363,8 +362,7 @@ func (s *Server) blockingRPC(opts *blockingOptions) error {
|
||||
opts.queryOpts.MaxQueryTime += lib.RandomStagger(opts.queryOpts.MaxQueryTime / jitterFraction)
|
||||
|
||||
// Setup a query timeout
|
||||
deadline = time.Now().Add(opts.queryOpts.MaxQueryTime)
|
||||
ctx, cancel = context.WithDeadline(context.Background(), deadline)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), opts.queryOpts.MaxQueryTime)
|
||||
defer cancel()
|
||||
|
||||
RUN_QUERY:
|
||||
|
||||
Reference in New Issue
Block a user