[shell]: volume balance capacity by min volume density (#8026)
volume balance by min volume density and active volumes
This commit is contained in:
committed by
GitHub
parent
7b8df39cf7
commit
01b3125815
@@ -262,3 +262,5 @@ const (
|
||||
PByte = TByte * 1000
|
||||
EByte = PByte * 1000
|
||||
)
|
||||
|
||||
const ErrVolumeNoSpaceLeft = "no space left for disk type"
|
||||
|
||||
@@ -44,6 +44,20 @@ func (s MinFreeSpace) IsLow(freeBytes uint64, freePercent float32) (yes bool, de
|
||||
return false, ""
|
||||
}
|
||||
|
||||
func (s MinFreeSpace) AvailableSpace(freeBytes uint64, totalBytes uint64) uint64 {
|
||||
var minFreeSpaceBytes uint64
|
||||
switch s.Type {
|
||||
case AsPercent:
|
||||
minFreeSpaceBytes = uint64((float32(totalBytes) * s.Percent) / 100)
|
||||
case AsBytes:
|
||||
minFreeSpaceBytes = s.Bytes
|
||||
}
|
||||
if minFreeSpaceBytes > freeBytes {
|
||||
return 0
|
||||
}
|
||||
return freeBytes - minFreeSpaceBytes
|
||||
}
|
||||
|
||||
// String returns a string representation of MinFreeSpace.
|
||||
func (s MinFreeSpace) String() string {
|
||||
switch s.Type {
|
||||
|
||||
Reference in New Issue
Block a user