(totalMemory string)
| 177 | } |
| 178 | |
| 179 | func (rc *ResourceControl) getMemoryCapacity(totalMemory string) (mem int64, err error) { |
| 180 | // memory capacity |
| 181 | // parse the configuration of total memory |
| 182 | var memoryQuotaConfiguration uint64 |
| 183 | if totalMemory != "" { |
| 184 | memoryQuotaConfiguration, err = bytefmt.ToBytes(totalMemory) |
| 185 | if err != nil { |
| 186 | return 0, err |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // parse memory limits from the cgroup |
| 191 | cgroupMemoryPath, err := rc.cgroupManager.GetCgroupSubsysPath("memory") |
| 192 | if err != nil { |
| 193 | return 0, err |
| 194 | } |
| 195 | totalMemoryQuota, err := cgroup.GetCgroupParamUint(cgroupMemoryPath, cgroup.MemoryLimitsFile) |
| 196 | if err != nil { |
| 197 | return 0, err |
| 198 | } |
| 199 | |
| 200 | // the final total memory equals to the configuration of total memory, when memory cgroup had no limits. |
| 201 | if totalMemoryQuota == cgroup.MemoryNoLimits && memoryQuotaConfiguration != 0 { |
| 202 | totalMemoryQuota = memoryQuotaConfiguration |
| 203 | } |
| 204 | return int64(totalMemoryQuota), nil |
| 205 | } |
| 206 | |
| 207 | func (rc *ResourceControl) getMilliCPUCapacity(totalCPU float64) (cpu int64, err error) { |
| 208 | // cpu capacity |
no test coverage detected