summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r--libpod/container_api.go34
1 files changed, 1 insertions, 33 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index bb9727ec1..b5104048e 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -717,39 +717,7 @@ func (c *Container) RestartWithTimeout(ctx context.Context, timeout uint) (err e
depString := strings.Join(notRunning, ",")
return errors.Wrapf(ErrCtrStateInvalid, "some dependencies of container %s are not started: %s", c.ID(), depString)
}
- if c.state.State == ContainerStateUnknown || c.state.State == ContainerStatePaused {
- return errors.Wrapf(ErrCtrStateInvalid, "unable to restart a container in a paused or unknown state")
- }
-
- if c.state.State == ContainerStateRunning {
- if err := c.stop(timeout); err != nil {
- return err
- }
- }
- if err := c.prepare(); err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if err2 := c.cleanup(); err2 != nil {
- logrus.Errorf("error cleaning up container %s: %v", c.ID(), err2)
- }
- }
- }()
-
- if c.state.State == ContainerStateStopped {
- // Reinitialize the container if we need to
- if err := c.reinit(ctx); err != nil {
- return err
- }
- } else if c.state.State == ContainerStateConfigured {
- // Initialize the container if it has never been initialized
- if err := c.init(ctx); err != nil {
- return err
- }
- }
-
- return c.start()
+ return c.restartWithTimeout(ctx, timeout)
}
// Refresh refreshes a container's state in the database, restarting the