aboutsummaryrefslogtreecommitdiff
path: root/pkg/specgenutil
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-07-21 23:01:03 +0200
committerGitHub <noreply@github.com>2022-07-21 23:01:03 +0200
commitee937c518e7efb9c47d21a4e1050b966ca02d005 (patch)
tree2cd2dfd0bcd1332a187f9cb66eff51a9591c4069 /pkg/specgenutil
parent34b2018cfc75772e89367614852c382ac47d3ec1 (diff)
parentc00ea686fef5a382849307d393226971fb1da1f3 (diff)
downloadpodman-ee937c518e7efb9c47d21a4e1050b966ca02d005.tar.gz
podman-ee937c518e7efb9c47d21a4e1050b966ca02d005.tar.bz2
podman-ee937c518e7efb9c47d21a4e1050b966ca02d005.zip
Merge pull request #14876 from cdoern/cgroup
resource limits for pods
Diffstat (limited to 'pkg/specgenutil')
-rw-r--r--pkg/specgenutil/specgen.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/specgenutil/specgen.go b/pkg/specgenutil/specgen.go
index 9a7d50947..4ab019b5b 100644
--- a/pkg/specgenutil/specgen.go
+++ b/pkg/specgenutil/specgen.go
@@ -74,6 +74,12 @@ func getCPULimits(c *entities.ContainerCreateOptions) *specs.LinuxCPU {
func getIOLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions) (*specs.LinuxBlockIO, error) {
var err error
io := &specs.LinuxBlockIO{}
+ if s.ResourceLimits == nil {
+ s.ResourceLimits = &specs.LinuxResources{}
+ }
+ if s.ResourceLimits.BlockIO == nil {
+ s.ResourceLimits.BlockIO = &specs.LinuxBlockIO{}
+ }
hasLimits := false
if b := c.BlkIOWeight; len(b) > 0 {
u, err := strconv.ParseUint(b, 10, 16)
@@ -82,6 +88,7 @@ func getIOLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions) (
}
nu := uint16(u)
io.Weight = &nu
+ s.ResourceLimits.BlockIO.Weight = &nu
hasLimits = true
}
@@ -96,6 +103,7 @@ func getIOLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions) (
if s.ThrottleReadBpsDevice, err = parseThrottleBPSDevices(bps); err != nil {
return nil, err
}
+
hasLimits = true
}
@@ -123,6 +131,8 @@ func getIOLimits(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions) (
if !hasLimits {
return nil, nil
}
+ io = s.ResourceLimits.BlockIO
+
return io, nil
}
@@ -509,7 +519,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions
return err
}
}
- if s.ResourceLimits.BlockIO == nil || (len(c.BlkIOWeight) != 0 || len(c.BlkIOWeightDevice) != 0) {
+ if s.ResourceLimits.BlockIO == nil || (len(c.BlkIOWeight) != 0 || len(c.BlkIOWeightDevice) != 0 || len(c.DeviceReadBPs) != 0 || len(c.DeviceWriteBPs) != 0) {
s.ResourceLimits.BlockIO, err = getIOLimits(s, c)
if err != nil {
return err