mirror of
https://github.com/minio/minio.git
synced 2025-11-20 09:56:07 -05:00
storage: Implement GetDiskID request in REST server side (#9720)
GetDiskID() in storage rest client does not really issue a REST request to the remote disk, but returns an in-memory value instead. However, GetDiskID() should return an error when format.json is not found or for other similar issues (unmounted disks, etc..) GetDiskID() is only called when formatting disks and getting storage informatio, hence this commit should not have a performance degradation.
This commit is contained in:
@@ -177,7 +177,19 @@ func (client *storageRESTClient) CrawlAndGetDataUsage(ctx context.Context, cache
|
||||
}
|
||||
|
||||
func (client *storageRESTClient) GetDiskID() (string, error) {
|
||||
return client.diskID, nil
|
||||
respBody, err := client.call(storageRESTMethodGetDiskID, nil, nil, -1)
|
||||
if err != nil {
|
||||
// Ignore when other nodes does not support GetDiskID call, this check
|
||||
// can be removed when the storage API version is bumped.
|
||||
if strings.Contains(err.Error(), "404 page not found") {
|
||||
return client.diskID, nil
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
defer http.DrainBody(respBody)
|
||||
var s string
|
||||
err = gob.NewDecoder(respBody).Decode(&s)
|
||||
return s, err
|
||||
}
|
||||
|
||||
func (client *storageRESTClient) SetDiskID(id string) {
|
||||
|
||||
Reference in New Issue
Block a user