From 3b88a646ec82a7f5d325af0748ca14d22ea12f56 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 4 Nov 2020 08:27:32 -0800 Subject: [PATCH] Add remote online/offline information (#10825) Log information about remote clients being marked offline. This will help to identify root causes of failures. --- cmd/rest/client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/rest/client.go b/cmd/rest/client.go index de87a1a99..0707fe7c2 100644 --- a/cmd/rest/client.go +++ b/cmd/rest/client.go @@ -28,6 +28,7 @@ import ( "time" xhttp "github.com/minio/minio/cmd/http" + "github.com/minio/minio/cmd/logger" xnet "github.com/minio/minio/pkg/net" ) @@ -117,6 +118,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod resp, err := c.httpClient.Do(req) if err != nil { if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) { + logger.Info("Marking %s temporary offline; caused by %v", c.url.String(), err) c.MarkOffline() } return nil, &NetworkError{err} @@ -139,6 +141,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod // fully it should make sure to respond with '412' // instead, see cmd/storage-rest-server.go for ideas. if resp.StatusCode == http.StatusPreconditionFailed { + logger.Info("Marking %s temporary offline; caused by PreconditionFailed.", c.url.String()) c.MarkOffline() } defer xhttp.DrainBody(resp.Body) @@ -146,6 +149,7 @@ func (c *Client) Call(ctx context.Context, method string, values url.Values, bod b, err := ioutil.ReadAll(io.LimitReader(resp.Body, c.MaxErrResponseSize)) if err != nil { if xnet.IsNetworkOrHostDown(err, c.ExpectTimeouts) { + logger.Info("Marking %s temporary offline; caused by %v", c.url.String(), err) c.MarkOffline() } return nil, err @@ -197,6 +201,7 @@ func (c *Client) MarkOffline() { } if c.HealthCheckFn() { atomic.CompareAndSwapInt32(&c.connected, offline, online) + logger.Info("Client %s online", c.url.String()) return } time.Sleep(time.Duration(r.Float64() * float64(c.HealthCheckInterval)))