Move online status to REST client (#9808)

This commit is contained in:
Klaus Post
2020-06-16 18:59:32 -07:00
committed by GitHub
parent 216de230e2
commit 3ba4804d6c
5 changed files with 91 additions and 57 deletions

View File

@@ -28,7 +28,6 @@ import (
"path"
"strconv"
"strings"
"sync/atomic"
"github.com/minio/minio/cmd/http"
"github.com/minio/minio/cmd/logger"
@@ -109,7 +108,6 @@ func toStorageErr(err error) error {
type storageRESTClient struct {
endpoint Endpoint
restClient *rest.Client
connected int32
diskID string
}
@@ -130,9 +128,6 @@ func (client *storageRESTClient) call(method string, values url.Values, body io.
}
err = toStorageErr(err)
if err == errDiskNotFound {
atomic.StoreInt32(&client.connected, 0)
}
return nil, err
}
@@ -144,7 +139,7 @@ func (client *storageRESTClient) String() string {
// IsOnline - returns whether RPC client failed to connect or not.
func (client *storageRESTClient) IsOnline() bool {
return atomic.LoadInt32(&client.connected) == 1
return client.restClient.IsOnline()
}
func (client *storageRESTClient) IsLocal() bool {
@@ -635,7 +630,6 @@ func (client *storageRESTClient) VerifyFile(volume, path string, fi FileInfo) er
// Close - marks the client as closed.
func (client *storageRESTClient) Close() error {
atomic.StoreInt32(&client.connected, 0)
client.restClient.Close()
return nil
}
@@ -660,8 +654,8 @@ func newStorageRESTClient(endpoint Endpoint) *storageRESTClient {
trFn := newCustomHTTPTransport(tlsConfig, rest.DefaultRESTTimeout)
restClient, err := rest.NewClient(serverURL, trFn, newAuthToken)
if err != nil {
logger.LogIf(GlobalContext, err)
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 0}
logger.Fatal(err, "Unable to initialize remote REST disks")
}
return &storageRESTClient{endpoint: endpoint, restClient: restClient, connected: 1}
restClient.HealthCheckPath = "/"
return &storageRESTClient{endpoint: endpoint, restClient: restClient}
}