diff options
-rw-r--r-- | cmd/podman/run.go | 10 | ||||
-rw-r--r-- | test/e2e/run_cgroup_parent_test.go | 58 |
2 files changed, 63 insertions, 5 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 32b3b9bdc..f13e293bc 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -84,10 +84,12 @@ func runCmd(c *cli.Context) error { return err } - logrus.Debug("new container created ", ctr.ID()) + if logrus.GetLevel() == logrus.DebugLevel { + logrus.Debugf("New container created %q", ctr.ID()) - p, _ := ctr.CGroupPath()("") - logrus.Debugf("createConfig.CgroupParent %v for %v", p, ctr.ID()) + p, _ := ctr.CGroupPath()("") + logrus.Debugf("container %q has CgroupParent %q", ctr.ID(), p) + } if err := ctr.Init(); err != nil { // This means the command did not exist @@ -107,8 +109,6 @@ func runCmd(c *cli.Context) error { return err } - logrus.Debug("new container created ", ctr.ID()) - if c.String("cidfile") != "" { if err := libpod.WriteFile(ctr.ID(), c.String("cidfile")); err != nil { logrus.Error(err) diff --git a/test/e2e/run_cgroup_parent_test.go b/test/e2e/run_cgroup_parent_test.go new file mode 100644 index 000000000..7647eb6d4 --- /dev/null +++ b/test/e2e/run_cgroup_parent_test.go @@ -0,0 +1,58 @@ +package integration + +import ( + "os" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +var _ = Describe("Podman run with --cgroup-parent", func() { + var ( + tempdir string + err error + podmanTest PodmanTest + ) + + BeforeEach(func() { + tempdir, err = CreateTempDirInTempDir() + if err != nil { + os.Exit(1) + } + podmanTest = PodmanCreate(tempdir) + podmanTest.RestoreAllArtifacts() + podmanTest.RestoreArtifact(fedoraMinimal) + }) + + AfterEach(func() { + podmanTest.Cleanup() + + }) + + Specify("valid --cgroup-parent using cgroupfs", func() { + cgroup := "/zzz" + run := podmanTest.Podman([]string{"run", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/self/cgroup"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(Equal(0)) + ok, _ := run.GrepString(cgroup) + Expect(ok).To(BeTrue()) + }) + + Specify("no --cgroup-parent", func() { + cgroup := "/libpod_parent" + run := podmanTest.Podman([]string{"run", fedoraMinimal, "cat", "/proc/self/cgroup"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(Equal(0)) + ok, _ := run.GrepString(cgroup) + Expect(ok).To(BeTrue()) + }) + + Specify("valid --cgroup-parent using slice", func() { + cgroup := "aaaa.slice" + run := podmanTest.Podman([]string{"run", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/1/cgroup"}) + run.WaitWithDefaultTimeout() + Expect(run.ExitCode()).To(Equal(0)) + ok, _ := run.GrepString(cgroup) + Expect(ok).To(BeTrue()) + }) +}) |