Soften limitation of update kernel memory

Kernel memory is not allowed to be updated if container is
running, it's not actually a precise kernel limitation.

Before kernel version 4.6, kernel memory will not be accounted
until kernel memory limit is set, if a container created with
kernel memory initialized, kernel memory is accounted as soon
as process created in container, so kernel memory limit update
is allowed afterward. If kernel memory is not initialized,
kernel memory consumed by processes in container will not be
accounted, so we can't update the limit because the account
will be wrong.

So update kernel memory of a running container with kernel memory
initialized is allowed, we should soften the limitation by docker.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang
2016-07-12 08:07:24 +08:00
parent 8f3be176d2
commit 08c7075c40
4 changed files with 53 additions and 18 deletions

View File

@@ -61,10 +61,6 @@ func (daemon *Daemon) update(name string, hostConfig *container.HostConfig) erro
return errCannotUpdate(container.ID, fmt.Errorf("Container is marked for removal and cannot be \"update\"."))
}
if container.IsRunning() && hostConfig.KernelMemory != 0 {
return errCannotUpdate(container.ID, fmt.Errorf("Can not update kernel memory to a running container, please stop it first."))
}
if err := container.UpdateContainer(hostConfig); err != nil {
restoreConfig = true
return errCannotUpdate(container.ID, err)