diff options
author | Matthew Heon <matthew.heon@pm.me> | 2021-03-03 16:34:18 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2021-03-04 12:32:09 -0500 |
commit | 8453424e2cfbe54b204b6fdb3515ea9f7f001023 (patch) | |
tree | 45d23bd9fea8be40d4f7a7921f58f460ef2f575d /cmd | |
parent | 87e20560ac885c541784af1341098ce8e1e7a940 (diff) | |
download | podman-8453424e2cfbe54b204b6fdb3515ea9f7f001023.tar.gz podman-8453424e2cfbe54b204b6fdb3515ea9f7f001023.tar.bz2 podman-8453424e2cfbe54b204b6fdb3515ea9f7f001023.zip |
Respect NanoCpus in Compat Create
The NanoCpus field in HostConfig was not wired up. It conflicts
with CPU period and quota (it hard-codes period to a specific
value and then sets the user-specified value as Quota).
Fixes #9523
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/common/create_opts.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index f945c9c54..add8f24fb 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -13,6 +13,7 @@ import ( "github.com/containers/podman/v3/pkg/domain/entities" "github.com/containers/podman/v3/pkg/rootless" "github.com/containers/podman/v3/pkg/specgen" + "github.com/pkg/errors" ) type ContainerCLIOpts struct { @@ -395,6 +396,13 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, cgroup cliOpts.Ulimit = ulimits } } + if cc.HostConfig.Resources.NanoCPUs > 0 { + if cliOpts.CPUPeriod != 0 || cliOpts.CPUQuota != 0 { + return nil, nil, errors.Errorf("NanoCpus conflicts with CpuPeriod and CpuQuota") + } + cliOpts.CPUPeriod = 100000 + cliOpts.CPUQuota = cc.HostConfig.Resources.NanoCPUs / 10000 + } // volumes volDestinations := make(map[string]bool) |