summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-20 08:39:11 +0000
committerGitHub <noreply@github.com>2021-10-20 08:39:11 +0000
commitfba7a05b1b24917b92faedfd097c7ab88c48bc5e (patch)
treecb0a554c30eddfd84af4645b6ed639e1fccf1946
parent7fa99358bd7e165f5b14b12b778614812ae42c8b (diff)
parent20b5a8599b11269c8812ce6c3df6d7f39ef1930c (diff)
downloadpodman-fba7a05b1b24917b92faedfd097c7ab88c48bc5e.tar.gz
podman-fba7a05b1b24917b92faedfd097c7ab88c48bc5e.tar.bz2
podman-fba7a05b1b24917b92faedfd097c7ab88c48bc5e.zip
Merge pull request #12024 from rhatdan/podman
podman run --memory=0 ... should not set memory limit
-rw-r--r--pkg/specgenutil/specgen.go12
-rw-r--r--test/system/030-run.bats5
2 files changed, 12 insertions, 5 deletions
diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go
index 6a6397257..8007e5d8e 100644
--- a/pkg/specgenutil/specgen.go
+++ b/pkg/specgenutil/specgen.go
@@ -133,12 +133,14 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOption
if err != nil {
return nil, errors.Wrapf(err, "invalid value for memory")
}
- memory.Limit = &ml
- if c.MemorySwap == "" {
- limit := 2 * ml
- memory.Swap = &(limit)
+ if ml > 0 {
+ memory.Limit = &ml
+ if c.MemorySwap == "" {
+ limit := 2 * ml
+ memory.Swap = &(limit)
+ }
+ hasLimits = true
}
- hasLimits = true
}
if m := c.MemoryReservation; len(m) > 0 {
mr, err := units.RAMInBytes(m)
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index 44c2ee509..2c8d08b99 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -67,6 +67,11 @@ echo $rand | 0 | $rand
is "$output" ".*invalidflag" "failed when passing undefined flags to the runtime"
}
+@test "podman run --memory=0 runtime option" {
+ run_podman run --memory=0 --rm $IMAGE echo hello
+ is "$output" "hello" "failed to run when --memory is set to 0"
+}
+
# 'run --preserve-fds' passes a number of additional file descriptors into the container
@test "podman run --preserve-fds" {
skip_if_remote "preserve-fds is meaningless over remote"