From 8c874884fcff5eb04b8f13cd1394c140149341e9 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 26 Apr 2023 12:13:54 -0700 Subject: [PATCH] fix: do not copy context in DiskInfo cache (#17085) --- cmd/storage-rest-client.go | 4 ++-- cmd/xl-storage.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/storage-rest-client.go b/cmd/storage-rest-client.go index 5a44e025f..d2721b76f 100644 --- a/cmd/storage-rest-client.go +++ b/cmd/storage-rest-client.go @@ -268,7 +268,7 @@ 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) { +func (client *storageRESTClient) DiskInfo(_ context.Context) (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 @@ -281,7 +281,7 @@ func (client *storageRESTClient) DiskInfo(ctx context.Context) (info DiskInfo, e client.diskInfoCache.TTL = time.Second client.diskInfoCache.Update = func() (interface{}, error) { var info DiskInfo - ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() respBody, err := client.call(ctx, storageRESTMethodDiskInfo, nil, nil, -1) if err != nil { diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 8e635a3fd..cee53c24c 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -607,7 +607,7 @@ func (s *xlStorage) NSScanner(ctx context.Context, cache dataUsageCache, updates // DiskInfo provides current information about disk space usage, // total free inodes and underlying filesystem. -func (s *xlStorage) DiskInfo(context.Context) (info DiskInfo, err error) { +func (s *xlStorage) DiskInfo(_ context.Context) (info DiskInfo, err error) { s.diskInfoCache.Once.Do(func() { s.diskInfoCache.TTL = time.Second s.diskInfoCache.Update = func() (interface{}, error) {