fix storage info output with unordered endpoints arguments (#9610)

Shuffling arguments that we pass to MinIO server are supported. However,
when that happens, Prometheus returns wrong information about disks usage
and online/offline status.

The commit fixes the issue by avoiding relying on xl.endpoints since
it is not ordered.
This commit is contained in:
Anis Elleuch
2020-05-19 22:27:20 +01:00
committed by GitHub
parent bd032d13ff
commit 9baeda781a
14 changed files with 75 additions and 41 deletions
+11 -4
View File
@@ -87,7 +87,9 @@ type posix struct {
activeIOCount int32
diskPath string
pool sync.Pool
hostname string
pool sync.Pool
diskMount bool // indicates if the path is an actual mount.
@@ -228,7 +230,7 @@ func isDirEmpty(dirname string) bool {
}
// Initialize a new storage disk.
func newPosix(path string) (*posix, error) {
func newPosix(path string, hostname string) (*posix, error) {
var err error
if path, err = getValidPath(path, true); err != nil {
return nil, err
@@ -239,6 +241,7 @@ func newPosix(path string) (*posix, error) {
}
p := &posix{
diskPath: path,
hostname: hostname,
pool: sync.Pool{
New: func() interface{} {
b := disk.AlignedBlock(readBlockSize)
@@ -339,8 +342,8 @@ func (s *posix) String() string {
return s.diskPath
}
func (*posix) Hostname() string {
return ""
func (s *posix) Hostname() string {
return s.hostname
}
func (s *posix) Close() error {
@@ -352,6 +355,10 @@ func (s *posix) IsOnline() bool {
return true
}
func (s *posix) IsLocal() bool {
return true
}
func (s *posix) waitForLowActiveIO() {
for atomic.LoadInt32(&s.activeIOCount) >= s.maxActiveIOCount {
time.Sleep(lowActiveIOWaitTick)