From fa325665b10fc0791fab5c9907c1bde8a569c92f Mon Sep 17 00:00:00 2001 From: Praveen raj Mani Date: Thu, 31 Oct 2019 21:43:54 +0530 Subject: [PATCH] Do not append the endpoint for fs/xl disks in StorageInfo (#8472) --- cmd/fs-v1.go | 3 +-- cmd/posix.go | 12 ++++++++++-- cmd/xl-v1.go | 6 ++++++ go.mod | 1 - 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd/fs-v1.go b/cmd/fs-v1.go index 0afd1d3eb..4f4d1a2f0 100644 --- a/cmd/fs-v1.go +++ b/cmd/fs-v1.go @@ -252,12 +252,11 @@ func (fs *FSObjects) StorageInfo(ctx context.Context) StorageInfo { if !fs.diskMount { used = atomic.LoadUint64(&fs.totalUsed) } - localPeer := GetLocalPeer(globalEndpoints) storageInfo := StorageInfo{ Used: []uint64{used}, Total: []uint64{di.Total}, Available: []uint64{di.Free}, - MountPaths: []string{localPeer + fs.fsPath}, + MountPaths: []string{fs.fsPath}, } storageInfo.Backend.Type = BackendFS return storageInfo diff --git a/cmd/posix.go b/cmd/posix.go index fefc00b4f..0e2645366 100644 --- a/cmd/posix.go +++ b/cmd/posix.go @@ -321,11 +321,15 @@ type DiskInfo struct { // total free inodes and underlying filesystem. func (s *posix) DiskInfo() (info DiskInfo, err error) { defer func() { - if err == errFaultyDisk { + if s != nil && err == errFaultyDisk { atomic.AddInt32(&s.ioErrCount, 1) } }() + if s == nil { + return info, errFaultyDisk + } + if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError { return info, errFaultyDisk } @@ -344,7 +348,11 @@ func (s *posix) DiskInfo() (info DiskInfo, err error) { if err != nil { return info, err } - localPeer := GetLocalPeer(globalEndpoints) + + localPeer := "" + if globalIsDistXL { + localPeer = GetLocalPeer(globalEndpoints) + } return DiskInfo{ Total: di.Total, diff --git a/cmd/xl-v1.go b/cmd/xl-v1.go index 72b8c516f..7338e4676 100644 --- a/cmd/xl-v1.go +++ b/cmd/xl-v1.go @@ -99,6 +99,10 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin getPeerAddress := func(diskPath string) (string, error) { hostPort := strings.Split(diskPath, SlashSeparator)[0] + // Host will be empty for xl/fs disk paths. + if hostPort == "" { + return "", nil + } thisAddr, err := xnet.ParseHost(hostPort) if err != nil { return "", err @@ -111,6 +115,7 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin // Wait for the routines. for i, err := range g.Wait() { peerAddr, pErr := getPeerAddress(disksInfo[i].RelativePath) + if pErr != nil { continue } @@ -122,6 +127,7 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin } if err != nil { offlineDisks[peerAddr]++ + continue } onlineDisks[peerAddr]++ } diff --git a/go.mod b/go.mod index 35af4bab6..a6662b78a 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,6 @@ require ( github.com/klauspost/reedsolomon v1.9.3 github.com/kurin/blazer v0.5.4-0.20190613185654-cf2f27cc0be3 github.com/lib/pq v1.0.0 - github.com/mattn/go-isatty v0.0.7 github.com/miekg/dns v1.1.8 github.com/minio/cli v1.22.0 github.com/minio/dsync/v2 v2.0.0