Add a custom healthcheck function for online status (#9858)

- Add changes to ensure remote disks are not
  incorrectly taken online if their order has
  changed or are incorrect disks.
- Bring changes to peer to detect disconnection
  with separate Health handler, to avoid a
  rather expensive call GetLocakDiskIDs()
- Follow up on the same changes for Lockers
  as well
This commit is contained in:
Harshavardhana
2020-06-17 14:49:26 -07:00
committed by GitHub
parent 16d7b90adf
commit 7ed1077879
11 changed files with 87 additions and 22 deletions

View File

@@ -18,11 +18,14 @@ package cmd
import (
"bytes"
"context"
"crypto/tls"
"errors"
"io"
"net/url"
"github.com/minio/minio/cmd/http"
xhttp "github.com/minio/minio/cmd/http"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/cmd/rest"
"github.com/minio/minio/pkg/dsync"
@@ -156,7 +159,14 @@ func newlockRESTClient(endpoint Endpoint) *lockRESTClient {
if err != nil {
logger.Fatal(err, "Unable to create lock rest client")
}
restClient.HealthCheckPath = "/"
restClient.HealthCheckFn = func() bool {
ctx, cancel := context.WithTimeout(GlobalContext, restClient.HealthCheckTimeout)
respBody, err := restClient.CallWithContext(ctx, lockRESTMethodHealth, nil, nil, -1)
xhttp.DrainBody(respBody)
cancel()
var ne *rest.NetworkError
return !errors.Is(err, context.DeadlineExceeded) && !errors.As(err, &ne)
}
return &lockRESTClient{endpoint: endpoint, restClient: restClient}
}