summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-11-07 10:44:33 -0600
committerbaude <bbaude@redhat.com>2018-11-07 10:44:33 -0600
commite022efa0f87b8c0d59ce8efeb370b3eeed145a28 (patch)
tree7c34987b1112f6c6de27a589f4ec92671d9f9d94 /libpod/container_internal.go
parent48914d67aed53ad793d86c98a6a4e96cfefe7333 (diff)
downloadpodman-e022efa0f87b8c0d59ce8efeb370b3eeed145a28.tar.gz
podman-e022efa0f87b8c0d59ce8efeb370b3eeed145a28.tar.bz2
podman-e022efa0f87b8c0d59ce8efeb370b3eeed145a28.zip
move defer'd function declaration ahead of prepare error return
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index d928c4aed..de15736f4 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -623,9 +623,6 @@ func (c *Container) initAndStart(ctx context.Context) (err error) {
return errors.Wrapf(ErrCtrStateInvalid, "cannot start paused container %s", c.ID())
}
- if err := c.prepare(); err != nil {
- return err
- }
defer func() {
if err != nil {
if err2 := c.cleanup(ctx); err2 != nil {
@@ -634,6 +631,10 @@ func (c *Container) initAndStart(ctx context.Context) (err error) {
}
}()
+ if err := c.prepare(); err != nil {
+ return err
+ }
+
// If we are ContainerStateStopped we need to remove from runtime
// And reset to ContainerStateConfigured
if c.state.State == ContainerStateStopped {
@@ -719,9 +720,6 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (err e
return err
}
}
- if err := c.prepare(); err != nil {
- return err
- }
defer func() {
if err != nil {
if err2 := c.cleanup(ctx); err2 != nil {
@@ -729,6 +727,9 @@ func (c *Container) restartWithTimeout(ctx context.Context, timeout uint) (err e
}
}
}()
+ if err := c.prepare(); err != nil {
+ return err
+ }
if c.state.State == ContainerStateStopped {
// Reinitialize the container if we need to