mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
Fix free drive space calculation in XL mode (#2917)
This commit is contained in:
parent
92858c7db2
commit
84acc820c7
@ -124,7 +124,13 @@ func printObjectAPIMsg() {
|
|||||||
|
|
||||||
// Get formatted disk/storage info message.
|
// Get formatted disk/storage info message.
|
||||||
func getStorageInfoMsg(storageInfo StorageInfo) string {
|
func getStorageInfoMsg(storageInfo StorageInfo) string {
|
||||||
msg := fmt.Sprintf("%s %s Free", colorBlue("Drive Capacity:"), humanize.IBytes(uint64(storageInfo.Free)))
|
freeSpace := uint64(storageInfo.Free)
|
||||||
|
totalSpace := uint64(storageInfo.Total)
|
||||||
|
if storageInfo.Backend.Type == XL {
|
||||||
|
freeSpace /= 2
|
||||||
|
totalSpace /= 2
|
||||||
|
}
|
||||||
|
msg := fmt.Sprintf("%s %s Free, %s Total", colorBlue("Drive Capacity:"), humanize.IBytes(freeSpace), humanize.IBytes(totalSpace))
|
||||||
diskInfo := fmt.Sprintf(" %d Online, %d Offline. We can withstand [%d] more drive failure(s).",
|
diskInfo := fmt.Sprintf(" %d Online, %d Offline. We can withstand [%d] more drive failure(s).",
|
||||||
storageInfo.Backend.OnlineDisks,
|
storageInfo.Backend.OnlineDisks,
|
||||||
storageInfo.Backend.OfflineDisks,
|
storageInfo.Backend.OfflineDisks,
|
||||||
|
@ -16,19 +16,26 @@
|
|||||||
|
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
// Tests if we generate storage info.
|
// Tests if we generate storage info.
|
||||||
func TestStorageInfoMsg(t *testing.T) {
|
func TestStorageInfoMsg(t *testing.T) {
|
||||||
obj, _, err := prepareXL()
|
infoStorage := StorageInfo{
|
||||||
if err != nil {
|
Total: 1024 * 1024 * 1024 * 10,
|
||||||
t.Fatal("Unable to initialize XL backend", err)
|
Free: 1024 * 1024 * 1024 * 2,
|
||||||
|
Backend: struct {
|
||||||
|
Type BackendType
|
||||||
|
OnlineDisks int
|
||||||
|
OfflineDisks int
|
||||||
|
ReadQuorum int
|
||||||
|
WriteQuorum int
|
||||||
|
}{XL, 7, 1, 4, 5},
|
||||||
}
|
}
|
||||||
globalObjLayerMutex.Lock()
|
|
||||||
globalObjectAPI = obj
|
|
||||||
globalObjLayerMutex.Unlock()
|
|
||||||
|
|
||||||
if msg := getStorageInfoMsg(obj.StorageInfo()); msg == "" {
|
if msg := getStorageInfoMsg(infoStorage); !strings.Contains(msg, "1.0 GiB Free, 5.0 GiB Total") || !strings.Contains(msg, "7 Online, 1 Offline") {
|
||||||
t.Fatal("Empty message string is not implemented")
|
t.Fatal("Empty message string is not implemented", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user