Configure resource-only container with memory limit

Fixed: #68928
The docker memory limit should base on the memory capacity of
machine. Currently CgroupManager specify wrong memory limit.
This commit is contained in:
FengyunPan2 2018-09-21 17:50:54 +08:00
parent 5dc2c13e74
commit 6af9e97fa5

View File

@ -101,8 +101,15 @@ func (m *containerManager) doWork() {
func createCgroupManager(name string) (*fs.Manager, error) {
var memoryLimit uint64
memoryCapacity, err := getMemoryCapacity()
if err != nil || memoryCapacity*dockerMemoryLimitThresholdPercent/100 < minDockerMemoryLimit {
if err != nil {
glog.Errorf("Failed to get the memory capacity on machine: %v", err)
} else {
memoryLimit = memoryCapacity * dockerMemoryLimitThresholdPercent / 100
}
if err != nil || memoryLimit < minDockerMemoryLimit {
memoryLimit = minDockerMemoryLimit
}
glog.V(2).Infof("Configure resource-only container %q with memory limit: %d", name, memoryLimit)