spec: fix order for setting rlimits
also make sure that the limits we set for rootless are not higher than what we'd set for root containers. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
18b273b72b
commit
76f8efc0d0
|
@ -545,10 +545,14 @@ func addRlimits(config *CreateConfig, g *generate.Generator) error {
|
||||||
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
|
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
|
||||||
logrus.Warnf("failed to return RLIMIT_NOFILE ulimit %q", err)
|
logrus.Warnf("failed to return RLIMIT_NOFILE ulimit %q", err)
|
||||||
}
|
}
|
||||||
current = rlimit.Cur
|
if rlimit.Cur < current {
|
||||||
max = rlimit.Max
|
current = rlimit.Cur
|
||||||
|
}
|
||||||
|
if rlimit.Max < max {
|
||||||
|
max = rlimit.Max
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.AddProcessRlimits("RLIMIT_NOFILE", current, max)
|
g.AddProcessRlimits("RLIMIT_NOFILE", max, current)
|
||||||
}
|
}
|
||||||
if !nprocSet {
|
if !nprocSet {
|
||||||
max := kernelMax
|
max := kernelMax
|
||||||
|
@ -558,10 +562,14 @@ func addRlimits(config *CreateConfig, g *generate.Generator) error {
|
||||||
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
|
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
|
||||||
logrus.Warnf("failed to return RLIMIT_NPROC ulimit %q", err)
|
logrus.Warnf("failed to return RLIMIT_NPROC ulimit %q", err)
|
||||||
}
|
}
|
||||||
current = rlimit.Cur
|
if rlimit.Cur < current {
|
||||||
max = rlimit.Max
|
current = rlimit.Cur
|
||||||
|
}
|
||||||
|
if rlimit.Max < max {
|
||||||
|
max = rlimit.Max
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.AddProcessRlimits("RLIMIT_NPROC", current, max)
|
g.AddProcessRlimits("RLIMIT_NPROC", max, current)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -21,7 +21,6 @@ var _ = Describe("Podman generate kube", func() {
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
SkipIfRootlessV2()
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -217,7 +217,6 @@ var _ = Describe("Podman generate kube", func() {
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
SkipIfRootlessV2()
|
|
||||||
tempdir, err = CreateTempDirInTempDir()
|
tempdir, err = CreateTempDirInTempDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in New Issue