diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-02-20 10:29:41 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-02-22 12:39:08 +0000 |
commit | 3f004df38482e0f66bde5cc78028d57d52219997 (patch) | |
tree | 73ca602de3b3953e583ae82296d5d793fad0606a | |
parent | f1f0f37dc142dc1687df1750c0d8c8fe1f79111a (diff) | |
download | podman-3f004df38482e0f66bde5cc78028d57d52219997.tar.gz podman-3f004df38482e0f66bde5cc78028d57d52219997.tar.bz2 podman-3f004df38482e0f66bde5cc78028d57d52219997.zip |
Implement podman run option --cgroup-parent
Example:
sudo /usr/local/bin/podman run --cgroup-parent=/zzz fedora cat /proc/self/cgroup
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Closes: #370
Approved by: rhatdan
-rw-r--r-- | cmd/podman/run.go | 5 | ||||
-rw-r--r-- | libpod/container.go | 2 | ||||
-rw-r--r-- | libpod/container_internal.go | 2 | ||||
-rw-r--r-- | libpod/options.go | 3 |
4 files changed, 9 insertions, 3 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 169fe6645..ca66aadf2 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -72,12 +72,17 @@ func runCmd(c *cli.Context) error { options = append(options, libpod.WithUser(createConfig.User)) options = append(options, libpod.WithShmDir(createConfig.ShmDir)) options = append(options, libpod.WithShmSize(createConfig.Resources.ShmSize)) + options = append(options, libpod.WithCgroupParent(createConfig.CgroupParent)) ctr, err := runtime.NewContainer(runtimeSpec, options...) if err != nil { return err } logrus.Debug("new container created ", ctr.ID()) + + p, _ := ctr.CGroupPath()("") + logrus.Debugf("createConfig.CgroupParent %v for %v", p, ctr.ID()) + if err := ctr.Init(); err != nil { // This means the command did not exist exitCode = 127 diff --git a/libpod/container.go b/libpod/container.go index d3a58d904..469b4180d 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -38,7 +38,7 @@ const ( ) // CgroupParent is the default prefix to a cgroup path in libpod -var CgroupParent = "/libpod_parent" +var DefaultCgroupParent = "/libpod_parent" // LinuxNS represents a Linux namespace type LinuxNS int diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 858cf3cbe..6e9852d1e 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -146,7 +146,7 @@ func newContainer(rspec *spec.Spec, lockDir string) (*Container, error) { ctr.config.CreatedTime = time.Now() ctr.config.ShmSize = DefaultShmSize - ctr.config.CgroupParent = CgroupParent + ctr.config.CgroupParent = DefaultCgroupParent // Path our lock file will reside at lockPath := filepath.Join(lockDir, ctr.config.ID) diff --git a/libpod/options.go b/libpod/options.go index 56e8fa203..6d3091378 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -656,6 +656,7 @@ func WithLogPath(path string) CtrCreateOption { } // WithCgroupParent sets the Cgroup Parent of the new container +// Default used if not overridden on command line func WithCgroupParent(parent string) CtrCreateOption { return func(ctr *Container) error { if ctr.valid { @@ -663,7 +664,7 @@ func WithCgroupParent(parent string) CtrCreateOption { } if parent == "" { - return errors.Wrapf(ErrInvalidArg, "cgroup parent cannot be empty") + return nil } ctr.config.CgroupParent = parent |