Skip to content

Commit

Permalink
Merge pull request #24547 from giuseppe/clamp-limits-userns
Browse files Browse the repository at this point in the history
spec: clamp rlimits in a userns
  • Loading branch information
openshift-merge-bot[bot] authored Nov 12, 2024
2 parents f41eab2 + 0a69aef commit 5f5783d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions libpod/container_internal_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,6 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
// setup rlimits
nofileSet := false
nprocSet := false
isRootless := rootless.IsRootless()
isRunningInUserNs := unshare.IsRootless()
if isRunningInUserNs && g.Config.Process != nil && g.Config.Process.OOMScoreAdj != nil {
var err error
Expand All @@ -682,7 +681,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
if !nofileSet {
max := rlimT(define.RLimitDefaultValue)
current := rlimT(define.RLimitDefaultValue)
if isRootless {
if isRunningInUserNs {
var rlimit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit); err != nil {
logrus.Warnf("Failed to return RLIMIT_NOFILE ulimit %q", err)
Expand All @@ -699,7 +698,7 @@ func (c *Container) generateSpec(ctx context.Context) (s *spec.Spec, cleanupFunc
if !nprocSet {
max := rlimT(define.RLimitDefaultValue)
current := rlimT(define.RLimitDefaultValue)
if isRootless {
if isRunningInUserNs {
var rlimit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NPROC, &rlimit); err != nil {
logrus.Warnf("Failed to return RLIMIT_NPROC ulimit %q", err)
Expand Down

0 comments on commit 5f5783d

Please sign in to comment.