From 95cb7a11f124b5d095e95a8928d752f38d6b375d Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Sat, 2 Dec 2017 06:00:53 -0500 Subject: kpod create should not do an OCI Init We need to differentiate between a kpod create and a kpod start kpod create should create all of the data for libpod, but kpod start should generate content for OCI Runtime (runc) in order to run. Signed-off-by: Daniel J Walsh Closes: #96 Approved by: mheon --- cmd/kpod/create.go | 4 ---- cmd/kpod/start.go | 5 +++++ test/kpod_pause.bats | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/kpod/create.go b/cmd/kpod/create.go index 9a4539c14..9e810af6e 100644 --- a/cmd/kpod/create.go +++ b/cmd/kpod/create.go @@ -211,10 +211,6 @@ func createCmd(c *cli.Context) error { } logrus.Debug("new container created ", ctr.ID()) - if err := ctr.Init(); err != nil { - return err - } - logrus.Debug("container storage created for %q", ctr.ID()) if c.String("cidfile") != "" { libpod.WriteFile(ctr.ID(), c.String("cidfile")) diff --git a/cmd/kpod/start.go b/cmd/kpod/start.go index 7f9918fa2..fcc4c9736 100644 --- a/cmd/kpod/start.go +++ b/cmd/kpod/start.go @@ -5,6 +5,7 @@ import ( "sync" "github.com/pkg/errors" + "github.com/projectatomic/libpod/libpod" "github.com/sirupsen/logrus" "github.com/urfave/cli" "os" @@ -82,6 +83,10 @@ func startCmd(c *cli.Context) error { continue } + if err := ctr.Init(); err != nil && errors.Cause(err) != libpod.ErrCtrExists { + return err + } + // We can only be interactive if both the config and the command-line say so if c.Bool("interactive") && !ctr.Config().Stdin { return errors.Errorf("the container was not created with the interactive option") diff --git a/test/kpod_pause.bats b/test/kpod_pause.bats index 3d6ab7b91..d26f0e4e1 100644 --- a/test/kpod_pause.bats +++ b/test/kpod_pause.bats @@ -23,7 +23,7 @@ function teardown() { } @test "pause a created container by id" { - run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} create $BB ls" + run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} run -d $BB sleep 60" echo "$output" [ "$status" -eq 0 ] ctr_id="$output" @@ -33,7 +33,7 @@ function teardown() { run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} unpause $ctr_id" echo "$output" [ "$status" -eq 0 ] - run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} rm $ctr_id" + run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} rm -f $ctr_id" echo "$output" [ "$status" -eq 0 ] } -- cgit v1.2.3-54-g00ecf