diff --git a/cmd/admin-handlers.go b/cmd/admin-handlers.go index d452b50ec..2ea8d54ef 100644 --- a/cmd/admin-handlers.go +++ b/cmd/admin-handlers.go @@ -292,7 +292,7 @@ func (a adminAPIHandlers) StorageInfoHandler(w http.ResponseWriter, r *http.Requ } // ignores any errors here. - storageInfo, _ := objectAPI.StorageInfo(ctx, false) + storageInfo, _ := objectAPI.StorageInfo(ctx) // Collect any disk healing. healing, _ := getAggregatedBackgroundHealState(ctx) diff --git a/cmd/erasure-server-sets.go b/cmd/erasure-server-sets.go index 1fe124e0d..ad361b383 100644 --- a/cmd/erasure-server-sets.go +++ b/cmd/erasure-server-sets.go @@ -289,7 +289,7 @@ func (z *erasureServerPools) BackendInfo() (b BackendInfo) { return } -func (z *erasureServerPools) StorageInfo(ctx context.Context, local bool) (StorageInfo, []error) { +func (z *erasureServerPools) StorageInfo(ctx context.Context) (StorageInfo, []error) { var storageInfo StorageInfo storageInfos := make([]StorageInfo, len(z.serverPools)) @@ -298,7 +298,7 @@ func (z *erasureServerPools) StorageInfo(ctx context.Context, local bool) (Stora for index := range z.serverPools { index := index g.Go(func() error { - storageInfos[index], storageInfosErrs[index] = z.serverPools[index].StorageInfo(ctx, local) + storageInfos[index], storageInfosErrs[index] = z.serverPools[index].StorageInfo(ctx) return nil }, index) } diff --git a/cmd/erasure-sets.go b/cmd/erasure-sets.go index 472362cab..e351c7d80 100644 --- a/cmd/erasure-sets.go +++ b/cmd/erasure-sets.go @@ -481,7 +481,7 @@ func (s *erasureSets) StorageUsageInfo(ctx context.Context) StorageInfo { index := index g.Go(func() error { // ignoring errors on purpose - storageInfos[index], _ = s.sets[index].StorageInfo(ctx, false) + storageInfos[index], _ = s.sets[index].StorageInfo(ctx) return nil }, index) } @@ -508,7 +508,7 @@ func (s *erasureSets) StorageUsageInfo(ctx context.Context) StorageInfo { } // StorageInfo - combines output of StorageInfo across all erasure coded object sets. -func (s *erasureSets) StorageInfo(ctx context.Context, local bool) (StorageInfo, []error) { +func (s *erasureSets) StorageInfo(ctx context.Context) (StorageInfo, []error) { var storageInfo StorageInfo storageInfos := make([]StorageInfo, len(s.sets)) @@ -518,7 +518,7 @@ func (s *erasureSets) StorageInfo(ctx context.Context, local bool) (StorageInfo, for index := range s.sets { index := index g.Go(func() error { - storageInfos[index], storageInfoErrs[index] = s.sets[index].StorageInfo(ctx, local) + storageInfos[index], storageInfoErrs[index] = s.sets[index].StorageInfo(ctx) return nil }, index) } @@ -530,12 +530,6 @@ func (s *erasureSets) StorageInfo(ctx context.Context, local bool) (StorageInfo, storageInfo.Disks = append(storageInfo.Disks, lstorageInfo.Disks...) } - if local { - // if local is true, we are not interested in the drive UUID info. - // this is called primarily by prometheus - return storageInfo, nil - } - var errs []error for i := range s.sets { errs = append(errs, storageInfoErrs[i]...) diff --git a/cmd/erasure.go b/cmd/erasure.go index b5d2d7357..2ac504b27 100644 --- a/cmd/erasure.go +++ b/cmd/erasure.go @@ -216,24 +216,9 @@ func getStorageInfo(disks []StorageAPI, endpoints []string) (StorageInfo, []erro } // StorageInfo - returns underlying storage statistics. -func (er erasureObjects) StorageInfo(ctx context.Context, local bool) (StorageInfo, []error) { +func (er erasureObjects) StorageInfo(ctx context.Context) (StorageInfo, []error) { disks := er.getDisks() endpoints := er.getEndpoints() - if local { - var localDisks []StorageAPI - var localEndpoints []string - for i, disk := range disks { - if disk != nil { - if disk.IsLocal() { - // Append this local disk since local flag is true - localDisks = append(localDisks, disk) - localEndpoints = append(localEndpoints, endpoints[i]) - } - } - } - disks = localDisks - endpoints = localEndpoints - } return getStorageInfo(disks, endpoints) } diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 28a99a297..e5e3281d7 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -206,8 +206,7 @@ func (fs *FSObjects) BackendInfo() BackendInfo { } // StorageInfo - returns underlying storage statistics. -func (fs *FSObjects) StorageInfo(ctx context.Context, _ bool) (StorageInfo, []error) { - +func (fs *FSObjects) StorageInfo(ctx context.Context) (StorageInfo, []error) { atomic.AddInt64(&fs.activeIOCount, 1) defer func() { atomic.AddInt64(&fs.activeIOCount, -1) diff --git a/cmd/gateway/azure/gateway-azure.go b/cmd/gateway/azure/gateway-azure.go index 217db7e64..c3685f5fd 100644 --- a/cmd/gateway/azure/gateway-azure.go +++ b/cmd/gateway/azure/gateway-azure.go @@ -561,7 +561,7 @@ func (a *azureObjects) Shutdown(ctx context.Context) error { } // StorageInfo - Not relevant to Azure backend. -func (a *azureObjects) StorageInfo(ctx context.Context, _ bool) (si minio.StorageInfo, _ []error) { +func (a *azureObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo, _ []error) { si.Backend.Type = minio.BackendGateway host := a.endpoint.Host if a.endpoint.Port() == "" { diff --git a/cmd/gateway/gcs/gateway-gcs.go b/cmd/gateway/gcs/gateway-gcs.go index 11f373e08..88623aff9 100644 --- a/cmd/gateway/gcs/gateway-gcs.go +++ b/cmd/gateway/gcs/gateway-gcs.go @@ -412,7 +412,7 @@ func (l *gcsGateway) Shutdown(ctx context.Context) error { } // StorageInfo - Not relevant to GCS backend. -func (l *gcsGateway) StorageInfo(ctx context.Context, _ bool) (si minio.StorageInfo, _ []error) { +func (l *gcsGateway) StorageInfo(ctx context.Context) (si minio.StorageInfo, _ []error) { si.Backend.Type = minio.BackendGateway si.Backend.GatewayOnline = minio.IsBackendOnline(ctx, "storage.googleapis.com:443") return si, nil diff --git a/cmd/gateway/hdfs/gateway-hdfs.go b/cmd/gateway/hdfs/gateway-hdfs.go index b25cb00f2..af4eaad54 100644 --- a/cmd/gateway/hdfs/gateway-hdfs.go +++ b/cmd/gateway/hdfs/gateway-hdfs.go @@ -214,7 +214,7 @@ func (n *hdfsObjects) Shutdown(ctx context.Context) error { return n.clnt.Close() } -func (n *hdfsObjects) StorageInfo(ctx context.Context, _ bool) (si minio.StorageInfo, errs []error) { +func (n *hdfsObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo, errs []error) { fsInfo, err := n.clnt.StatFs() if err != nil { return minio.StorageInfo{}, []error{err} diff --git a/cmd/gateway/nas/gateway-nas.go b/cmd/gateway/nas/gateway-nas.go index 357127405..311fba59a 100644 --- a/cmd/gateway/nas/gateway-nas.go +++ b/cmd/gateway/nas/gateway-nas.go @@ -104,8 +104,8 @@ func (n *nasObjects) IsListenSupported() bool { return false } -func (n *nasObjects) StorageInfo(ctx context.Context, _ bool) (si minio.StorageInfo, _ []error) { - si, errs := n.ObjectLayer.StorageInfo(ctx, false) +func (n *nasObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo, _ []error) { + si, errs := n.ObjectLayer.StorageInfo(ctx) si.Backend.GatewayOnline = si.Backend.Type == minio.BackendFS si.Backend.Type = minio.BackendGateway return si, errs diff --git a/cmd/gateway/s3/gateway-s3.go b/cmd/gateway/s3/gateway-s3.go index 328daa264..98f2353e9 100644 --- a/cmd/gateway/s3/gateway-s3.go +++ b/cmd/gateway/s3/gateway-s3.go @@ -274,7 +274,7 @@ func (l *s3Objects) Shutdown(ctx context.Context) error { } // StorageInfo is not relevant to S3 backend. -func (l *s3Objects) StorageInfo(ctx context.Context, _ bool) (si minio.StorageInfo, _ []error) { +func (l *s3Objects) StorageInfo(ctx context.Context) (si minio.StorageInfo, _ []error) { si.Backend.Type = minio.BackendGateway host := l.Client.EndpointURL().Host if l.Client.EndpointURL().Port() == "" { diff --git a/cmd/metrics.go b/cmd/metrics.go index d680e6494..912cd46e9 100644 --- a/cmd/metrics.go +++ b/cmd/metrics.go @@ -497,10 +497,11 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) { return } - // Fetch disk space info, ignore errors - storageInfo, _ := objLayer.StorageInfo(GlobalContext, true) + server := getLocalServerProperty(globalEndpoints, &http.Request{ + Host: GetLocalPeer(globalEndpoints), + }) - onlineDisks, offlineDisks := getOnlineOfflineDisksStats(storageInfo.Disks) + onlineDisks, offlineDisks := getOnlineOfflineDisksStats(server.Disks) totalDisks := offlineDisks.Merge(onlineDisks) // MinIO Offline Disks per node @@ -523,7 +524,7 @@ func storageMetricsPrometheus(ch chan<- prometheus.Metric) { float64(totalDisks.Sum()), ) - for _, disk := range storageInfo.Disks { + for _, disk := range server.Disks { // Total disk usage by the disk ch <- prometheus.MustNewConstMetric( prometheus.NewDesc( diff --git a/cmd/object-api-interface.go b/cmd/object-api-interface.go index 460e68faa..2cb310cd0 100644 --- a/cmd/object-api-interface.go +++ b/cmd/object-api-interface.go @@ -82,7 +82,7 @@ type ObjectLayer interface { CrawlAndGetDataUsage(ctx context.Context, bf *bloomFilter, updates chan<- DataUsageInfo) error BackendInfo() BackendInfo - StorageInfo(ctx context.Context, local bool) (StorageInfo, []error) // local queries only local disks + StorageInfo(ctx context.Context) (StorageInfo, []error) // local queries only local disks // Bucket operations. MakeBucketWithLocation(ctx context.Context, bucket string, opts BucketOptions) error diff --git a/cmd/server-startup-msg.go b/cmd/server-startup-msg.go index 21b7935a8..acc09e9db 100644 --- a/cmd/server-startup-msg.go +++ b/cmd/server-startup-msg.go @@ -47,7 +47,7 @@ func getFormatStr(strLen int, padding int) string { } func mustGetStorageInfo(objAPI ObjectLayer) StorageInfo { - storageInfo, _ := objAPI.StorageInfo(GlobalContext, false) + storageInfo, _ := objAPI.StorageInfo(GlobalContext) return storageInfo }