aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-08 14:37:14 +0200
committerGitHub <noreply@github.com>2022-09-08 14:37:14 +0200
commit95eff1aa402c3d159c8ad25d8140b879d5feccf2 (patch)
treeac190060179ecf6f44e9990952d5ef65dddb3068
parentd117d086b7d714ababc3dc14e1f80064dc9e9e57 (diff)
parent911e4a1389c6c0ae435d8dc36378fdc2bbfe3eee (diff)
downloadpodman-95eff1aa402c3d159c8ad25d8140b879d5feccf2.tar.gz
podman-95eff1aa402c3d159c8ad25d8140b879d5feccf2.tar.bz2
podman-95eff1aa402c3d159c8ad25d8140b879d5feccf2.zip
Merge pull request #15667 from dfr/freebsd-specgen
specgen/generate: Factor out setting resource limits from CompleteSpec
-rw-r--r--pkg/specgen/generate/container.go15
-rw-r--r--pkg/specgen/resources_freebsd.go8
-rw-r--r--pkg/specgen/resources_linux.go22
3 files changed, 31 insertions, 14 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 46b7a2dc2..c4fbda9e5 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -18,7 +18,6 @@ import (
envLib "github.com/containers/podman/v4/pkg/env"
"github.com/containers/podman/v4/pkg/signal"
"github.com/containers/podman/v4/pkg/specgen"
- spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/openshift/imagebuilder"
"github.com/sirupsen/logrus"
)
@@ -272,19 +271,7 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
}
// If caller did not specify Pids Limits load default
- 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,
- }
- }
- }
- }
+ s.InitResourceLimits(rtc)
if s.LogConfiguration == nil {
s.LogConfiguration = &specgen.LogConfig{}
diff --git a/pkg/specgen/resources_freebsd.go b/pkg/specgen/resources_freebsd.go
new file mode 100644
index 000000000..49e5976bb
--- /dev/null
+++ b/pkg/specgen/resources_freebsd.go
@@ -0,0 +1,8 @@
+package specgen
+
+import (
+ "github.com/containers/common/pkg/config"
+)
+
+func (s *SpecGenerator) InitResourceLimits(rtc *config.Config) {
+}
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,
+ }
+ }
+ }
+ }
+}