Skip to content

Commit

Permalink
monitor: Handle EOF errors, improve network error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Aug 19, 2024
1 parent b291b2e commit 0150273
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ func CheckHost(ctx context.Context, ip *netip.Addr, cfg *pb.Config, traceAttribu
resp, err := ntp.QueryWithOptions(ipStr, opts)
if err != nil {
r := &response{
Status: &pb.ServerStatus{},
Status: &pb.ServerStatus{
NoResponse: true,
},
}
r.Status.SetIP(ip)
if resp != nil {
Expand All @@ -104,7 +106,10 @@ func CheckHost(ctx context.Context, ip *netip.Addr, cfg *pb.Config, traceAttribu
if netErr, ok := err.(*net.OpError); ok {
// drop the protocol and addresses
r.Error = fmt.Errorf("network: %w", netErr.Err)
} else {
r.Error = err
}
r.Status.Error = r.Error.Error()

responses = append(responses, r)

Expand Down Expand Up @@ -151,7 +156,7 @@ func CheckHost(ctx context.Context, ip *netip.Addr, cfg *pb.Config, traceAttribu

var best *response

// log.Printf("for %s we collected %d samples, now find the best result", ip.String(), len(statuses))
// log.Debug("collection done, now find the best result", "ip", ip.String(), "count", len(responses))

// todo: if there are more than 2 (3?) samples with an offset, throw
// away the offset outlier(s)
Expand Down

0 comments on commit 0150273

Please # to comment.