WatchCtx propogates context error

This commit is contained in:
Alex Dadgar
2017-08-31 13:03:35 -07:00
parent 9317318f49
commit e5670d0f9f
2 changed files with 2 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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: