Skip to content

Commit

Permalink
Merge pull request #9607 from mheon/fix_9523
Browse files Browse the repository at this point in the history
Respect NanoCpus in Compat Create
  • Loading branch information
openshift-merge-robot authored Mar 4, 2021
2 parents a26b152 + 8453424 commit 4e5cc6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/common/create_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,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
volSources := make(map[string]bool)
Expand Down
9 changes: 9 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,12 @@ t GET containers/json 200 \
.[0].Ports[0].Type="tcp"

podman stop bar

# Test CPU limit (NanoCPUs)
t POST containers/create '"Image":"'$IMAGE'","HostConfig":{"NanoCpus":500000}' 201 \
.Id~[0-9a-f]\\{64\\}
cid=$(jq -r '.Id' <<<"$output")
t GET containers/$cid/json 200 \
.HostConfig.NanoCpus=500000

t DELETE containers/$cid?v=true 204

0 comments on commit 4e5cc6a

Please sign in to comment.