|
|
|
@ -28,6 +28,7 @@ import ( |
|
|
|
|
"path" |
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/minio/minio/cmd/http" |
|
|
|
|
xhttp "github.com/minio/minio/cmd/http" |
|
|
|
@ -115,6 +116,8 @@ type storageRESTClient struct { |
|
|
|
|
endpoint Endpoint |
|
|
|
|
restClient *rest.Client |
|
|
|
|
diskID string |
|
|
|
|
|
|
|
|
|
diskInfoCache timedValue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Wrapper to restClient.Call to handle network errors, in case of network error the connection is makred disconnected
|
|
|
|
@ -195,19 +198,28 @@ func (client *storageRESTClient) SetDiskID(id string) { |
|
|
|
|
|
|
|
|
|
// DiskInfo - fetch disk information for a remote disk.
|
|
|
|
|
func (client *storageRESTClient) DiskInfo(ctx context.Context) (info DiskInfo, err error) { |
|
|
|
|
respBody, err := client.call(ctx, storageRESTMethodDiskInfo, nil, nil, -1) |
|
|
|
|
if err != nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
defer http.DrainBody(respBody) |
|
|
|
|
err = gob.NewDecoder(respBody).Decode(&info) |
|
|
|
|
if err != nil { |
|
|
|
|
return info, err |
|
|
|
|
} |
|
|
|
|
if info.Error != "" { |
|
|
|
|
return info, toStorageErr(errors.New(info.Error)) |
|
|
|
|
} |
|
|
|
|
return info, nil |
|
|
|
|
client.diskInfoCache.Once.Do(func() { |
|
|
|
|
client.diskInfoCache.TTL = time.Second |
|
|
|
|
client.diskInfoCache.Update = func() (interface{}, error) { |
|
|
|
|
var info DiskInfo |
|
|
|
|
respBody, err := client.call(ctx, storageRESTMethodDiskInfo, nil, nil, -1) |
|
|
|
|
if err != nil { |
|
|
|
|
return info, err |
|
|
|
|
} |
|
|
|
|
defer http.DrainBody(respBody) |
|
|
|
|
err = gob.NewDecoder(respBody).Decode(&info) |
|
|
|
|
if err != nil { |
|
|
|
|
return info, err |
|
|
|
|
} |
|
|
|
|
if info.Error != "" { |
|
|
|
|
return info, toStorageErr(errors.New(info.Error)) |
|
|
|
|
} |
|
|
|
|
return info, nil |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
v, err := client.diskInfoCache.Get() |
|
|
|
|
info = v.(DiskInfo) |
|
|
|
|
return info, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// MakeVolBulk - create multiple volumes in a bulk operation.
|
|
|
|
|