summaryrefslogtreecommitdiff
path: root/pkg/specgen/resources_linux.go
blob: ffa9e5786f0b0ca402ec5497a7199a09018d420e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package specgen

import (
	"github.com/containers/common/pkg/config"
	spec "github.com/opencontainers/runtime-spec/specs-go"
)

func (s *SpecGenerator) InitResourceLimits(rtc *config.Config) {
	if s.ResourceLimits == nil || s.ResourceLimits.Pids == nil {
		if s.CgroupsMode != "disabled" {
			limit := rtc.PidsLimit()
			if limit != 0 {
				if s.ResourceLimits == nil {
					s.ResourceLimits = &spec.LinuxResources{}
				}
				s.ResourceLimits.Pids = &spec.LinuxPids{
					Limit: limit,
				}
			}
		}
	}
}