@ -19,7 +19,6 @@ package cmd
import (
import (
"bytes"
"bytes"
"context"
"context"
"errors"
"io"
"io"
"net/url"
"net/url"
"strconv"
"strconv"
@ -28,6 +27,7 @@ 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
@ -153,15 +153,15 @@ func newlockRESTClient(endpoint Endpoint) *lockRESTClient {
restClient := rest . NewClient ( serverURL , globalInternodeTransport , newAuthToken )
restClient := rest . NewClient ( serverURL , globalInternodeTransport , newAuthToken )
restClient . ExpectTimeouts = true
restClient . ExpectTimeouts = true
// Use a separate client to avoid recursive calls.
healthClient := rest . NewClient ( serverURL , globalInternodeTransport , newAuthToken )
healthClient . ExpectTimeouts = true
restClient . HealthCheckFn = func ( ) bool {
restClient . HealthCheckFn = func ( ) bool {
ctx , cancel := context . WithTimeout ( GlobalContext , restClient . HealthCheckTimeout )
ctx , cancel := context . WithTimeout ( GlobalContext , restClient . HealthCheckTimeout )
// Instantiate a new rest client for healthcheck
defer cancel ( )
// to avoid recursive healthCheckFn()
respBody , err := healthClient . Call ( ctx , lockRESTMethodHealth , nil , nil , - 1 )
respBody , err := rest . NewClient ( serverURL , globalInternodeTransport , newAuthToken ) . Call ( ctx , lockRESTMethodHealth , nil , nil , - 1 )
xhttp . DrainBody ( respBody )
xhttp . DrainBody ( respBody )
cancel ( )
return ! xnet . IsNetworkOrHostDown ( err , false )
var ne * rest . NetworkError
return ! errors . Is ( err , context . DeadlineExceeded ) && ! errors . As ( err , & ne )
}
}
return & lockRESTClient { endpoint : endpoint , restClient : restClient }
return & lockRESTClient { endpoint : endpoint , restClient : restClient }