Adds a warning if the context is canceled.

This commit is contained in:
James Phillips 2017-03-20 09:27:28 -07:00
parent 90d9963570
commit e8bbce82a2
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 6 additions and 3 deletions

View File

@ -43,7 +43,8 @@ func (f *StatsFetcher) fetch(server *agent.Server, replyCh chan *structs.ServerS
var reply structs.ServerStats var reply structs.ServerStats
err := f.pool.RPC(f.datacenter, server.Addr, server.Version, "Status.RaftStats", &args, &reply) err := f.pool.RPC(f.datacenter, server.Addr, server.Version, "Status.RaftStats", &args, &reply)
if err != nil { if err != nil {
f.logger.Printf("[WARN] consul: error getting server health from %q: %v", server.Name, err) f.logger.Printf("[WARN] consul: error getting server health from %q: %v",
server.Name, err)
} else { } else {
replyCh <- &reply replyCh <- &reply
} }
@ -65,7 +66,8 @@ func (f *StatsFetcher) Fetch(ctx context.Context, servers []*agent.Server) map[s
f.inflightLock.Lock() f.inflightLock.Lock()
for _, server := range servers { for _, server := range servers {
if _, ok := f.inflight[server.ID]; ok { if _, ok := f.inflight[server.ID]; ok {
f.logger.Printf("[WARN] consul: error getting server health from %q: last request still outstanding", server.Name) f.logger.Printf("[WARN] consul: error getting server health from %q: last request still outstanding",
server.Name)
} else { } else {
workItem := &workItem{ workItem := &workItem{
server: server, server: server,
@ -87,7 +89,8 @@ func (f *StatsFetcher) Fetch(ctx context.Context, servers []*agent.Server) map[s
replies[workItem.server.ID] = reply replies[workItem.server.ID] = reply
case <-ctx.Done(): case <-ctx.Done():
// Give up on this and any remaining outstanding RPCs. f.logger.Printf("[WARN] consul: error getting server health from %q: %v",
workItem.server.Name, ctx.Err())
} }
} }
return replies return replies