mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix reserved memory is zero
This commit is contained in:
@@ -831,6 +831,9 @@ func (h *SHostInfo) getReservedMem() int {
|
||||
if reserved > options.HostOptions.MaxReservedMemory {
|
||||
return options.HostOptions.MaxReservedMemory
|
||||
}
|
||||
if reserved == 0 {
|
||||
panic("memory reserve value is 0, need help")
|
||||
}
|
||||
return reserved
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,10 @@ func DetectMemoryInfo() (*SMemory, error) {
|
||||
return nil, err
|
||||
}
|
||||
smem.MemInfo = sysutils.ParseDMIMemInfo(strings.Split(string(ret), "\n"))
|
||||
if smem.MemInfo.Total == 0 {
|
||||
// in case dmidecode is not work, use gopsutil
|
||||
smem.MemInfo.Total = smem.Total
|
||||
}
|
||||
return smem, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user