mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Stopping a stopped container should not be an error
Resolves: #575 Signed-off-by: baude <bbaude@redhat.com> Closes: #588 Approved by: mheon
This commit is contained in:
@ -101,7 +101,7 @@ func stopCmd(c *cli.Context) error {
|
|||||||
} else {
|
} else {
|
||||||
stopTimeout = ctr.StopTimeout()
|
stopTimeout = ctr.StopTimeout()
|
||||||
}
|
}
|
||||||
if err := ctr.StopWithTimeout(stopTimeout); err != nil {
|
if err := ctr.StopWithTimeout(stopTimeout); err != nil && err != libpod.ErrCtrStopped {
|
||||||
if lastError != nil {
|
if lastError != nil {
|
||||||
fmt.Fprintln(os.Stderr, lastError)
|
fmt.Fprintln(os.Stderr, lastError)
|
||||||
}
|
}
|
||||||
|
@ -215,6 +215,10 @@ func (c *Container) Stop() error {
|
|||||||
return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers")
|
return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.state.State == ContainerStateStopped {
|
||||||
|
return ErrCtrStopped
|
||||||
|
}
|
||||||
|
|
||||||
return c.stop(c.config.StopTimeout)
|
return c.stop(c.config.StopTimeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,6 +241,10 @@ func (c *Container) StopWithTimeout(timeout uint) error {
|
|||||||
return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers")
|
return errors.Wrapf(ErrCtrStateInvalid, "can only stop created, running, or stopped containers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.state.State == ContainerStateStopped {
|
||||||
|
return ErrCtrStopped
|
||||||
|
}
|
||||||
|
|
||||||
return c.stop(timeout)
|
return c.stop(timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user