summaryrefslogtreecommitdiff
path: root/pkg/specgen/resources_linux.go
diff options
context:
space:
mode:
authorDoug Rabson <dfr@rabson.org>2022-09-05 13:55:51 +0100
committerDoug Rabson <dfr@rabson.org>2022-09-08 08:24:18 +0100
commit911e4a1389c6c0ae435d8dc36378fdc2bbfe3eee (patch)
tree16510d1de04a7b2ca40ffba1412e6c1fd3f3cf64 /pkg/specgen/resources_linux.go
parentac8c1e1c22e5a2a69dc067523aa7faeeed79abdd (diff)
downloadpodman-911e4a1389c6c0ae435d8dc36378fdc2bbfe3eee.tar.gz
podman-911e4a1389c6c0ae435d8dc36378fdc2bbfe3eee.tar.bz2
podman-911e4a1389c6c0ae435d8dc36378fdc2bbfe3eee.zip
specgen/generate: Factor out setting resource limits from CompleteSpec
This avoids setting values in the spec which are not supported on FreeBSD - including these values causes warning messages for the unsupported features. [NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson <dfr@rabson.org>
Diffstat (limited to 'pkg/specgen/resources_linux.go')
-rw-r--r--pkg/specgen/resources_linux.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/pkg/specgen/resources_linux.go b/pkg/specgen/resources_linux.go
new file mode 100644
index 000000000..ffa9e5786
--- /dev/null
+++ b/pkg/specgen/resources_linux.go
@@ -0,0 +1,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,
+ }
+ }
+ }
+ }
+}