diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-18 16:14:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-18 16:14:52 +0200 |
commit | ade0d8778f39b854fed3523bc17afbd98cc5a886 (patch) | |
tree | a6c7a77c97620a8585016ed28ddbfada4029b584 /pkg/spec/spec.go | |
parent | 22e62e8691495dd5385e23e51901b357e2891a74 (diff) | |
parent | 0b57e77d7c1c54706611c9ca15e352425adb05e5 (diff) | |
download | podman-ade0d8778f39b854fed3523bc17afbd98cc5a886.tar.gz podman-ade0d8778f39b854fed3523bc17afbd98cc5a886.tar.bz2 podman-ade0d8778f39b854fed3523bc17afbd98cc5a886.zip |
Merge pull request #3509 from giuseppe/cgroup-namespace
libpod: support for cgroup namespace
Diffstat (limited to 'pkg/spec/spec.go')
-rw-r--r-- | pkg/spec/spec.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index 41054633f..a8ab4911a 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -325,6 +325,10 @@ func (config *CreateConfig) createConfigToOCISpec(runtime *libpod.Runtime, userM if err := addIpcNS(config, &g); err != nil { return nil, err } + + if err := addCgroupNS(config, &g); err != nil { + return nil, err + } configSpec := g.Config // HANDLE CAPABILITIES @@ -622,6 +626,23 @@ func addIpcNS(config *CreateConfig, g *generate.Generator) error { return nil } +func addCgroupNS(config *CreateConfig, g *generate.Generator) error { + cgroupMode := config.CgroupMode + if cgroupMode.IsNS() { + return g.AddOrReplaceLinuxNamespace(string(spec.CgroupNamespace), NS(string(cgroupMode))) + } + if cgroupMode.IsHost() { + return g.RemoveLinuxNamespace(spec.CgroupNamespace) + } + if cgroupMode.IsPrivate() { + return g.AddOrReplaceLinuxNamespace(spec.CgroupNamespace, "") + } + if cgroupMode.IsContainer() { + logrus.Debug("Using container cgroup mode") + } + return nil +} + func addRlimits(config *CreateConfig, g *generate.Generator) error { var ( kernelMax uint64 = 1048576 |