mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
move defer'd function declaration ahead of prepare error return
Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user