summaryrefslogtreecommitdiff
path: root/libpod/container_api.go
diff options
context:
space:
mode:
authorhaircommander <pehunt@redhat.com>2018-07-23 15:56:12 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-25 17:54:27 +0000
commit7789284cbe8f5068d66c90c257b9784505d4a027 (patch)
tree864b09233236bdb699a98a67006d0bc47de40c94 /libpod/container_api.go
parente56717833e52db68a334018a43a0b1a698d30aa8 (diff)
downloadpodman-7789284cbe8f5068d66c90c257b9784505d4a027.tar.gz
podman-7789284cbe8f5068d66c90c257b9784505d4a027.tar.bz2
podman-7789284cbe8f5068d66c90c257b9784505d4a027.zip
Added pod.Restart() functionality to libpod.
Moved contents of RestartWithTimeout to restartWithTimeout in container_internal to be able to call restart without locking in function. Refactored startNode to be able to either start or restart a node. Built pod Restart() with new startNode with refresh true. Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1152 Approved by: rhatdan
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