aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-26 09:31:38 -0400
committerGitHub <noreply@github.com>2020-06-26 09:31:38 -0400
commitd721f1fee68db8f9e12c83855654da0d7d985140 (patch)
treea58e14991d6811e5b1b4ef5b2216e531f067c30b
parentbb11b428798094f33b3ec6102d2e52a3baf46324 (diff)
parent43c19966f67fed9ec6551efcd0a96231fbf40e56 (diff)
downloadpodman-d721f1fee68db8f9e12c83855654da0d7d985140.tar.gz
podman-d721f1fee68db8f9e12c83855654da0d7d985140.tar.bz2
podman-d721f1fee68db8f9e12c83855654da0d7d985140.zip
Merge pull request #6786 from rhafer/rootless_rlimit
specgen: fix order for setting rlimits
-rw-r--r--pkg/specgen/generate/oci.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 1c34f622b..badb34999 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -52,10 +52,14 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) error {
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
logrus.Warnf("failed to return RLIMIT_NOFILE ulimit %q", err)
}
- current = rlimit.Cur
- max = rlimit.Max
+ if rlimit.Cur < current {
+ current = rlimit.Cur
+ }
+ if rlimit.Max < max {
+ max = rlimit.Max
+ }
}
- g.AddProcessRlimits("RLIMIT_NOFILE", current, max)
+ g.AddProcessRlimits("RLIMIT_NOFILE", max, current)
}
if !nprocSet {
max := kernelMax
@@ -65,10 +69,14 @@ func addRlimits(s *specgen.SpecGenerator, g *generate.Generator) error {
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
logrus.Warnf("failed to return RLIMIT_NPROC ulimit %q", err)
}
- current = rlimit.Cur
- max = rlimit.Max
+ if rlimit.Cur < current {
+ current = rlimit.Cur
+ }
+ if rlimit.Max < max {
+ max = rlimit.Max
+ }
}
- g.AddProcessRlimits("RLIMIT_NPROC", current, max)
+ g.AddProcessRlimits("RLIMIT_NPROC", max, current)
}
return nil