summaryrefslogtreecommitdiff
path: root/pkg/spec/config_linux.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-10-02 00:51:48 -0700
committerGitHub <noreply@github.com>2018-10-02 00:51:48 -0700
commitabdaf79dac76efcd27ac8c7b719ec8d4107921bd (patch)
tree7c4691160cfa3c435c88f311e7f071348c843dc5 /pkg/spec/config_linux.go
parent3bdccd8a461217ac6d0094c2081f50612d60c19a (diff)
parentabde1ef0ef890d716d4e6d2dff89fdffc25b8295 (diff)
downloadpodman-abdaf79dac76efcd27ac8c7b719ec8d4107921bd.tar.gz
podman-abdaf79dac76efcd27ac8c7b719ec8d4107921bd.tar.bz2
podman-abdaf79dac76efcd27ac8c7b719ec8d4107921bd.zip
Merge pull request #1547 from giuseppe/rootless-error-on-invalid-resources
rootless: raise an error when trying to use cgroups
Diffstat (limited to 'pkg/spec/config_linux.go')
-rw-r--r--pkg/spec/config_linux.go25
1 files changed, 17 insertions, 8 deletions
diff --git a/pkg/spec/config_linux.go b/pkg/spec/config_linux.go
index 6c0a99419..20cdcc458 100644
--- a/pkg/spec/config_linux.go
+++ b/pkg/spec/config_linux.go
@@ -91,18 +91,23 @@ func getSeccompConfig(config *CreateConfig, configSpec *spec.Spec) (*spec.LinuxS
}
func (c *CreateConfig) createBlockIO() (*spec.LinuxBlockIO, error) {
+ var ret *spec.LinuxBlockIO
bio := &spec.LinuxBlockIO{}
- bio.Weight = &c.Resources.BlkioWeight
+ if c.Resources.BlkioWeight > 0 {
+ ret = bio
+ bio.Weight = &c.Resources.BlkioWeight
+ }
if len(c.Resources.BlkioWeightDevice) > 0 {
var lwds []spec.LinuxWeightDevice
+ ret = bio
for _, i := range c.Resources.BlkioWeightDevice {
wd, err := validateweightDevice(i)
if err != nil {
- return bio, errors.Wrapf(err, "invalid values for blkio-weight-device")
+ return ret, errors.Wrapf(err, "invalid values for blkio-weight-device")
}
wdStat, err := getStatFromPath(wd.path)
if err != nil {
- return bio, errors.Wrapf(err, "error getting stat from path %q", wd.path)
+ return ret, errors.Wrapf(err, "error getting stat from path %q", wd.path)
}
lwd := spec.LinuxWeightDevice{
Weight: &wd.weight,
@@ -114,34 +119,38 @@ func (c *CreateConfig) createBlockIO() (*spec.LinuxBlockIO, error) {
bio.WeightDevice = lwds
}
if len(c.Resources.DeviceReadBps) > 0 {
+ ret = bio
readBps, err := makeThrottleArray(c.Resources.DeviceReadBps, bps)
if err != nil {
- return bio, err
+ return ret, err
}
bio.ThrottleReadBpsDevice = readBps
}
if len(c.Resources.DeviceWriteBps) > 0 {
+ ret = bio
writeBpds, err := makeThrottleArray(c.Resources.DeviceWriteBps, bps)
if err != nil {
- return bio, err
+ return ret, err
}
bio.ThrottleWriteBpsDevice = writeBpds
}
if len(c.Resources.DeviceReadIOps) > 0 {
+ ret = bio
readIOps, err := makeThrottleArray(c.Resources.DeviceReadIOps, iops)
if err != nil {
- return bio, err
+ return ret, err
}
bio.ThrottleReadIOPSDevice = readIOps
}
if len(c.Resources.DeviceWriteIOps) > 0 {
+ ret = bio
writeIOps, err := makeThrottleArray(c.Resources.DeviceWriteIOps, iops)
if err != nil {
- return bio, err
+ return ret, err
}
bio.ThrottleWriteIOPSDevice = writeIOps
}
- return bio, nil
+ return ret, nil
}
func makeThrottleArray(throttleInput []string, rateType int) ([]spec.LinuxThrottleDevice, error) {