mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
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
This commit is contained in:

committed by
Atomic Bot

parent
e56717833e
commit
7789284cbe
@ -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
|
||||
|
Reference in New Issue
Block a user