fix: optimize DiskInfo() call avoid metrics when not needed (#17763)

This commit is contained in:
Harshavardhana
2023-07-31 15:20:48 -07:00
committed by GitHub
parent 8162fd1e20
commit 81be718674
27 changed files with 92 additions and 63 deletions

View File

@@ -272,7 +272,7 @@ func (client *storageRESTClient) SetDiskID(id string) {
}
// DiskInfo - fetch disk information for a remote disk.
func (client *storageRESTClient) DiskInfo(_ context.Context) (info DiskInfo, err error) {
func (client *storageRESTClient) DiskInfo(_ context.Context, metrics bool) (info DiskInfo, err error) {
if !client.IsOnline() {
// make sure to check if the disk is offline, since the underlying
// value is cached we should attempt to invalidate it if such calls
@@ -287,7 +287,10 @@ func (client *storageRESTClient) DiskInfo(_ context.Context) (info DiskInfo, err
var info DiskInfo
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
respBody, err := client.call(ctx, storageRESTMethodDiskInfo, nil, nil, -1)
vals := make(url.Values)
vals.Set(storageRESTMetrics, strconv.FormatBool(metrics))
respBody, err := client.call(ctx, storageRESTMethodDiskInfo, vals, nil, -1)
if err != nil {
return info, err
}