server: Add more elaborate startup messages. (#2731)

These messages based on our prep stage during XL
and prints more informative message regarding
drive information.

This change also does a much needed refactoring.
This commit is contained in:
Harshavardhana
2016-10-05 12:48:07 -07:00
committed by GitHub
parent 63a7ca1af0
commit 6494b77d41
61 changed files with 1505 additions and 1340 deletions

View File

@@ -40,10 +40,11 @@ const (
// posix - implements StorageAPI interface.
type posix struct {
ioErrCount int32 // ref: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
diskPath string
minFreeSpace int64
minFreeInodes int64
ioErrCount int32 // ref: https://golang.org/pkg/sync/atomic/#pkg-note-BUG
diskPath string
suppliedDiskPath string
minFreeSpace int64
minFreeInodes int64
}
var errFaultyDisk = errors.New("Faulty disk")
@@ -95,6 +96,10 @@ func newPosix(diskPath string) (StorageAPI, error) {
if diskPath == "" {
return nil, errInvalidArgument
}
suppliedDiskPath := diskPath
if idx := strings.LastIndex(diskPath, ":"); idx != -1 {
diskPath = diskPath[idx+1:]
}
var err error
// Disallow relative paths, figure out absolute paths.
diskPath, err = filepath.Abs(diskPath)
@@ -102,9 +107,10 @@ func newPosix(diskPath string) (StorageAPI, error) {
return nil, err
}
fs := &posix{
diskPath: diskPath,
minFreeSpace: fsMinFreeSpace,
minFreeInodes: fsMinFreeInodesPercent,
suppliedDiskPath: suppliedDiskPath,
diskPath: diskPath,
minFreeSpace: fsMinFreeSpace,
minFreeInodes: fsMinFreeInodesPercent,
}
st, err := os.Stat(preparePath(diskPath))
if err != nil {
@@ -162,6 +168,11 @@ func (s posix) checkDiskFree() (err error) {
return nil
}
// Implements stringer compatible interface.
func (s *posix) String() string {
return s.suppliedDiskPath
}
// DiskInfo provides current information about disk space usage,
// total free inodes and underlying filesystem.
func (s *posix) DiskInfo() (info disk.Info, err error) {