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:
baude
2018-04-03 10:43:58 -05:00
committed by Atomic Bot
parent 4640e79667
commit b1a8d769b8
2 changed files with 9 additions and 1 deletions

View File

@ -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)
} }

View File

@ -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)
} }