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/createconfig.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/createconfig.go')
-rw-r--r-- | pkg/spec/createconfig.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 0042ed401..1fb1f829b 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -63,6 +63,7 @@ type CreateConfig struct { CapDrop []string // cap-drop CidFile string ConmonPidFile string + Cgroupns string CgroupParent string // cgroup-parent Command []string Detach bool // detach @@ -101,6 +102,7 @@ type CreateConfig struct { NetworkAlias []string //network-alias PidMode namespaces.PidMode //pid Pod string //pod + CgroupMode namespaces.CgroupMode //cgroup PortBindings nat.PortMap Privileged bool //privileged Publish []string //publish @@ -268,6 +270,23 @@ func (c *CreateConfig) getContainerCreateOptions(runtime *libpod.Runtime, pod *l options = append(options, libpod.WithNetNS(portBindings, postConfigureNetNS, string(c.NetMode), networks)) } + if c.CgroupMode.IsNS() { + ns := c.CgroupMode.NS() + if ns == "" { + return nil, errors.Errorf("invalid empty user-defined network namespace") + } + _, err := os.Stat(ns) + if err != nil { + return nil, err + } + } else if c.CgroupMode.IsContainer() { + connectedCtr, err := runtime.LookupContainer(c.CgroupMode.Container()) + if err != nil { + return nil, errors.Wrapf(err, "container %q not found", c.CgroupMode.Container()) + } + options = append(options, libpod.WithCgroupNSFrom(connectedCtr)) + } + if c.PidMode.IsContainer() { connectedCtr, err := runtime.LookupContainer(c.PidMode.Container()) if err != nil { |