From f64c1f106c4148a8432e8a8b28e967f2a47fd3a8 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 2 Apr 2018 12:29:31 -0400 Subject: Remove explicit Init() calls in run and start We no longer require an explicit Init() to start a container, as Start() will now call Init() if the container is not initialized. Remove explicit Init() invocations from run and start to help with dependency ordering - less time for a dependency to go down before we start. Signed-off-by: Matthew Heon Closes: #577 Approved by: rhatdan --- cmd/podman/run.go | 24 ++++++++++++------------ cmd/podman/start.go | 4 ---- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 10f68e9da..0c174a729 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -108,16 +108,6 @@ func runCmd(c *cli.Context) error { logrus.Debugf("container %q has CgroupParent %q", ctr.ID(), p) } - if err := ctr.Init(); err != nil { - // This means the command did not exist - exitCode = 127 - if strings.Index(err.Error(), "permission denied") > -1 { - exitCode = 126 - } - return err - } - logrus.Debugf("container storage created for %q", ctr.ID()) - createConfigJSON, err := json.Marshal(createConfig) if err != nil { return err @@ -135,7 +125,12 @@ func runCmd(c *cli.Context) error { // Handle detached start if createConfig.Detach { if err := ctr.Start(); err != nil { - return errors.Wrapf(err, "unable to start container %q", ctr.ID()) + // This means the command did not exist + exitCode = 127 + if strings.Index(err.Error(), "permission denied") > -1 { + exitCode = 126 + } + return err } fmt.Printf("%s\n", ctr.ID()) @@ -147,7 +142,12 @@ func runCmd(c *cli.Context) error { // Handle this when we split streams to allow attaching just stdin/out/err attachChan, err := ctr.StartAndAttach(false, c.String("detach-keys")) if err != nil { - return errors.Wrapf(err, "unable to start container %q", ctr.ID()) + // This means the command did not exist + exitCode = 127 + if strings.Index(err.Error(), "permission denied") > -1 { + exitCode = 126 + } + return err } if c.BoolT("sig-proxy") { diff --git a/cmd/podman/start.go b/cmd/podman/start.go index 366d5c3fc..1a57a538b 100644 --- a/cmd/podman/start.go +++ b/cmd/podman/start.go @@ -91,10 +91,6 @@ 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") -- cgit v1.2.3-54-g00ecf