Adds a warning if the context is canceled.

This commit is contained in:
James Phillips 2017-03-20 09:27:28 -07:00
parent 5ee1256137
commit 898b26524a
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
err := f.pool.RPC(f.datacenter, server.Addr, server.Version, "Status.RaftStats", &args, &reply)
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 {
replyCh <- &reply
}
@ -65,7 +66,8 @@ func (f *StatsFetcher) Fetch(ctx context.Context, servers []*agent.Server) map[s
f.inflightLock.Lock()
for _, server := range servers {
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 {
workItem := &workItem{
server: server,
@ -87,7 +89,8 @@ func (f *StatsFetcher) Fetch(ctx context.Context, servers []*agent.Server) map[s
replies[workItem.server.ID] = reply
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