Skip to content

Commit

Permalink
Fix some log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Mar 15, 2019
1 parent b1dc866 commit 24300ba
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion api/apihttp/apihttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,12 @@ func LogHandler(handle http.Handler) http.HandlerFunc {
latency := time.Now().Sub(start)

log.Debugf("Request: lat %d %+v", latency, request)
if writer.status >= 400 {
if writer.status >= 400 && writer.status < 500 {
log.Infof("Bad Request: %d %+v", latency, request)
}
if writer.status >= 500 {
log.Infof("Server error: %d %+v", latency, request)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion balloon/balloon.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (b Balloon) QueryDigestMembership(keyDigest hashing.Digest, version uint64)
historyProof, historyErr = b.historyTree.ProveMembership(proof.ActualVersion, version)
}()
} else {
return nil, fmt.Errorf("query version %d is not on history tree which version is %d", version, proof.ActualVersion)
return nil, fmt.Errorf("query version %d is greater than the actual version which is %d", version, proof.ActualVersion)
}

}
Expand Down
11 changes: 9 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ func (c *HTTPClient) doReq(method string, endpoint *endpoint, path string, data
// Get response
resp, err := c.retrier.DoReq(req)
if err != nil {
log.Infof("%s is dead", endpoint)
log.Infof("Request error: %v\n", err)
log.Infof("%s is dead\n", endpoint)
endpoint.MarkAsDead()
return nil, err
}
Expand Down Expand Up @@ -378,7 +379,13 @@ func (c *HTTPClient) discover() error {
return nil
}

for _, e := range c.topology.Endpoints() {
for {

e, err := c.topology.NextReadEndpoint(Any)
if err != nil {
return err
}

body, err := c.doReq("GET", e, "/info/shards", nil)
if err == nil {
info := make(map[string]interface{})
Expand Down
4 changes: 2 additions & 2 deletions client/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func (r *NoRequestRetrier) DoReq(req *RetriableRequest) (*http.Response, error)
if err == nil && resp.StatusCode > 0 && resp.StatusCode < 500 {
return resp, nil
}
return nil, fmt.Errorf("%s %s giving up after %d attempts",
req.Method, req.URL, 1)
return nil, fmt.Errorf("%s %s returned %d: giving up after %d attempts",
req.Method, req.URL, resp.StatusCode, 1)
}

// BackoffRequestRetrier is an implementation that uses the given backoff strategy.
Expand Down
1 change: 0 additions & 1 deletion cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func newClientCommand(ctx *cmdContext) *cobra.Command {
clientCtx.config.EnableTopologyDiscovery = false
clientCtx.config.EnableHealthChecks = false
clientCtx.config.MaxRetries = 0
clientCtx.config.ReadPreference = client.Any

client, err := client.NewHTTPClientFromConfig(clientCtx.config)
if err != nil {
Expand Down

0 comments on commit 24300ba

Please sign in to comment.