mirror of
https://github.com/containers/podman.git
synced 2025-05-21 17:16:22 +08:00
Merge pull request #25908 from Honny1/fix-ulimits-compat-api-with-rootless
Fix: Compat API in rootless mode ignores ulimits
This commit is contained in:
@ -486,15 +486,15 @@ func cliOpts(cc handlers.CreateContainerConfig, rtc *config.Config) (*entities.C
|
|||||||
HealthMaxLogCount: define.DefaultHealthMaxLogCount,
|
HealthMaxLogCount: define.DefaultHealthMaxLogCount,
|
||||||
HealthMaxLogSize: define.DefaultHealthMaxLogSize,
|
HealthMaxLogSize: define.DefaultHealthMaxLogSize,
|
||||||
}
|
}
|
||||||
if !rootless.IsRootless() {
|
|
||||||
var ulimits []string
|
var ulimits []string
|
||||||
if len(cc.HostConfig.Ulimits) > 0 {
|
if len(cc.HostConfig.Ulimits) > 0 {
|
||||||
for _, ul := range cc.HostConfig.Ulimits {
|
for _, ul := range cc.HostConfig.Ulimits {
|
||||||
ulimits = append(ulimits, ul.String())
|
ulimits = append(ulimits, ul.String())
|
||||||
}
|
|
||||||
cliOpts.Ulimit = ulimits
|
|
||||||
}
|
}
|
||||||
|
cliOpts.Ulimit = ulimits
|
||||||
}
|
}
|
||||||
|
|
||||||
if cc.HostConfig.Resources.NanoCPUs > 0 {
|
if cc.HostConfig.Resources.NanoCPUs > 0 {
|
||||||
if cliOpts.CPUPeriod != 0 || cliOpts.CPUQuota != 0 {
|
if cliOpts.CPUPeriod != 0 || cliOpts.CPUQuota != 0 {
|
||||||
return nil, nil, fmt.Errorf("NanoCpus conflicts with CpuPeriod and CpuQuota")
|
return nil, nil, fmt.Errorf("NanoCpus conflicts with CpuPeriod and CpuQuota")
|
||||||
|
@ -419,6 +419,21 @@ t GET containers/$cid/json 200 \
|
|||||||
|
|
||||||
t DELETE containers/$cid?v=true 204
|
t DELETE containers/$cid?v=true 204
|
||||||
|
|
||||||
|
|
||||||
|
# test compact API in rootless mode ignores ulimits https://github.com/containers/podman/issues/25881
|
||||||
|
t POST containers/create \
|
||||||
|
Image=$IMAGE \
|
||||||
|
HostConfig='{"Ulimits":[{"Name":"cpu","Soft":1,"Hard":2}]}' \
|
||||||
|
201 \
|
||||||
|
.Id~[0-9a-f]\\{64\\}
|
||||||
|
cid=$(jq -r '.Id' <<<"$output")
|
||||||
|
t GET containers/$cid/json 200 \
|
||||||
|
.HostConfig.Ulimits[0].Name="RLIMIT_CPU" \
|
||||||
|
.HostConfig.Ulimits[0].Hard=2 \
|
||||||
|
.HostConfig.Ulimits[0].Soft=1 \
|
||||||
|
|
||||||
|
t DELETE containers/$cid 204
|
||||||
|
|
||||||
# test port mapping
|
# test port mapping
|
||||||
podman run -d --rm --name bar -p 8080:9090 $IMAGE top
|
podman run -d --rm --name bar -p 8080:9090 $IMAGE top
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user