From db7a9b2c37567213d8c41d80b3a7e4b7acb65660 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 14 Oct 2022 00:41:44 +0100 Subject: [PATCH] heal-info: Return the endpoint of a disk with unknown state (#15854) --- cmd/erasure.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/erasure.go b/cmd/erasure.go index a55cfe9b2..7dcf58ca4 100644 --- a/cmd/erasure.go +++ b/cmd/erasure.go @@ -107,7 +107,6 @@ func (d byDiskTotal) Less(i, j int) bool { } func diskErrToDriveState(err error) (state string) { - state = madmin.DriveStateUnknown switch { case errors.Is(err, errDiskNotFound): state = madmin.DriveStateOffline @@ -121,7 +120,10 @@ func diskErrToDriveState(err error) (state string) { state = madmin.DriveStateFaulty case err == nil: state = madmin.DriveStateOk + default: + state = fmt.Sprintf("%s (cause: %s)", madmin.DriveStateUnknown, err) } + return } @@ -184,18 +186,19 @@ func getDisksInfo(disks []StorageAPI, endpoints []Endpoint) (disksInfo []madmin. for index := range disks { index := index g.Go(func() error { + diskEndpoint := endpoints[index].String() if disks[index] == OfflineDisk { logger.LogIf(GlobalContext, fmt.Errorf("%s: %s", errDiskNotFound, endpoints[index])) disksInfo[index] = madmin.Disk{ State: diskErrToDriveState(errDiskNotFound), - Endpoint: endpoints[index].String(), + Endpoint: diskEndpoint, } // Storage disk is empty, perhaps ignored disk or not available. return errDiskNotFound } info, err := disks[index].DiskInfo(context.TODO()) di := madmin.Disk{ - Endpoint: info.Endpoint, + Endpoint: diskEndpoint, DrivePath: info.MountPath, TotalSpace: info.Total, UsedSpace: info.Used,