fix: network shutdown was not handle properly (#10927)

fixes a regression introduced in #10859, due
to the error returned by rest.Client being typed
i.e *rest.NetworkError - IsNetworkHostDown function
didn't work as expected to detect network issues.

This in-turn aggravated the situations when nodes
are disconnected leading to performance loss.
This commit is contained in:
Harshavardhana 2020-11-19 13:53:49 -08:00 committed by GitHub
parent 0f9e125cf3
commit f794fe79e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -27,7 +27,6 @@ import (
xhttp "github.com/minio/minio/cmd/http" xhttp "github.com/minio/minio/cmd/http"
"github.com/minio/minio/cmd/rest" "github.com/minio/minio/cmd/rest"
"github.com/minio/minio/pkg/dsync" "github.com/minio/minio/pkg/dsync"
xnet "github.com/minio/minio/pkg/net"
) )
// lockRESTClient is authenticable lock REST client // lockRESTClient is authenticable lock REST client
@ -161,7 +160,7 @@ func newlockRESTClient(endpoint Endpoint) *lockRESTClient {
defer cancel() defer cancel()
respBody, err := healthClient.Call(ctx, lockRESTMethodHealth, nil, nil, -1) respBody, err := healthClient.Call(ctx, lockRESTMethodHealth, nil, nil, -1)
xhttp.DrainBody(respBody) xhttp.DrainBody(respBody)
return !xnet.IsNetworkOrHostDown(err, false) return !isNetworkError(err)
} }
return &lockRESTClient{endpoint: endpoint, restClient: restClient} return &lockRESTClient{endpoint: endpoint, restClient: restClient}

View File

@ -882,7 +882,7 @@ func newPeerRESTClient(peer *xnet.Host) *peerRESTClient {
defer cancel() defer cancel()
respBody, err := healthClient.Call(ctx, peerRESTMethodHealth, nil, nil, -1) respBody, err := healthClient.Call(ctx, peerRESTMethodHealth, nil, nil, -1)
xhttp.DrainBody(respBody) xhttp.DrainBody(respBody)
return !xnet.IsNetworkOrHostDown(err, false) return !isNetworkError(err)
} }
return &peerRESTClient{host: peer, restClient: restClient} return &peerRESTClient{host: peer, restClient: restClient}

View File

@ -626,7 +626,7 @@ func newStorageRESTClient(endpoint Endpoint, healthcheck bool) *storageRESTClien
respBody, err := healthClient.Call(ctx, storageRESTMethodHealth, nil, nil, -1) respBody, err := healthClient.Call(ctx, storageRESTMethodHealth, nil, nil, -1)
xhttp.DrainBody(respBody) xhttp.DrainBody(respBody)
cancel() cancel()
return !xnet.IsNetworkOrHostDown(err, false) && toStorageErr(err) != errDiskNotFound return toStorageErr(err) != errDiskNotFound
} }
} }

View File

@ -147,12 +147,15 @@ func IsNetworkOrHostDown(err error, expectTimeouts bool) bool {
if err == nil { if err == nil {
return false return false
} }
if errors.Is(err, context.Canceled) { if errors.Is(err, context.Canceled) {
return false return false
} }
if expectTimeouts && errors.Is(err, context.DeadlineExceeded) { if expectTimeouts && errors.Is(err, context.DeadlineExceeded) {
return false return false
} }
// We need to figure if the error either a timeout // We need to figure if the error either a timeout
// or a non-temporary error. // or a non-temporary error.
e, ok := err.(net.Error) e, ok := err.(net.Error)