Do not append the endpoint for fs/xl disks in StorageInfo (#8472)

This commit is contained in:
Praveen raj Mani 2019-10-31 21:43:54 +05:30 committed by kannappanr
parent eac518b178
commit fa325665b1
4 changed files with 17 additions and 5 deletions

View File

@ -252,12 +252,11 @@ func (fs *FSObjects) StorageInfo(ctx context.Context) StorageInfo {
if !fs.diskMount { if !fs.diskMount {
used = atomic.LoadUint64(&fs.totalUsed) used = atomic.LoadUint64(&fs.totalUsed)
} }
localPeer := GetLocalPeer(globalEndpoints)
storageInfo := StorageInfo{ storageInfo := StorageInfo{
Used: []uint64{used}, Used: []uint64{used},
Total: []uint64{di.Total}, Total: []uint64{di.Total},
Available: []uint64{di.Free}, Available: []uint64{di.Free},
MountPaths: []string{localPeer + fs.fsPath}, MountPaths: []string{fs.fsPath},
} }
storageInfo.Backend.Type = BackendFS storageInfo.Backend.Type = BackendFS
return storageInfo return storageInfo

View File

@ -321,11 +321,15 @@ type DiskInfo struct {
// total free inodes and underlying filesystem. // total free inodes and underlying filesystem.
func (s *posix) DiskInfo() (info DiskInfo, err error) { func (s *posix) DiskInfo() (info DiskInfo, err error) {
defer func() { defer func() {
if err == errFaultyDisk { if s != nil && err == errFaultyDisk {
atomic.AddInt32(&s.ioErrCount, 1) atomic.AddInt32(&s.ioErrCount, 1)
} }
}() }()
if s == nil {
return info, errFaultyDisk
}
if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError { if atomic.LoadInt32(&s.ioErrCount) > maxAllowedIOError {
return info, errFaultyDisk return info, errFaultyDisk
} }
@ -344,7 +348,11 @@ func (s *posix) DiskInfo() (info DiskInfo, err error) {
if err != nil { if err != nil {
return info, err return info, err
} }
localPeer := GetLocalPeer(globalEndpoints)
localPeer := ""
if globalIsDistXL {
localPeer = GetLocalPeer(globalEndpoints)
}
return DiskInfo{ return DiskInfo{
Total: di.Total, Total: di.Total,

View File

@ -99,6 +99,10 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin
getPeerAddress := func(diskPath string) (string, error) { getPeerAddress := func(diskPath string) (string, error) {
hostPort := strings.Split(diskPath, SlashSeparator)[0] hostPort := strings.Split(diskPath, SlashSeparator)[0]
// Host will be empty for xl/fs disk paths.
if hostPort == "" {
return "", nil
}
thisAddr, err := xnet.ParseHost(hostPort) thisAddr, err := xnet.ParseHost(hostPort)
if err != nil { if err != nil {
return "", err return "", err
@ -111,6 +115,7 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin
// Wait for the routines. // Wait for the routines.
for i, err := range g.Wait() { for i, err := range g.Wait() {
peerAddr, pErr := getPeerAddress(disksInfo[i].RelativePath) peerAddr, pErr := getPeerAddress(disksInfo[i].RelativePath)
if pErr != nil { if pErr != nil {
continue continue
} }
@ -122,6 +127,7 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks, offlin
} }
if err != nil { if err != nil {
offlineDisks[peerAddr]++ offlineDisks[peerAddr]++
continue
} }
onlineDisks[peerAddr]++ onlineDisks[peerAddr]++
} }

1
go.mod
View File

@ -36,7 +36,6 @@ require (
github.com/klauspost/reedsolomon v1.9.3 github.com/klauspost/reedsolomon v1.9.3
github.com/kurin/blazer v0.5.4-0.20190613185654-cf2f27cc0be3 github.com/kurin/blazer v0.5.4-0.20190613185654-cf2f27cc0be3
github.com/lib/pq v1.0.0 github.com/lib/pq v1.0.0
github.com/mattn/go-isatty v0.0.7
github.com/miekg/dns v1.1.8 github.com/miekg/dns v1.1.8
github.com/minio/cli v1.22.0 github.com/minio/cli v1.22.0
github.com/minio/dsync/v2 v2.0.0 github.com/minio/dsync/v2 v2.0.0