mirror of
https://github.com/containers/podman.git
synced 2025-06-17 23:20:59 +08:00
Fix podman-remote stop --all to handle not running containers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -87,10 +87,25 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
|
|||||||
}
|
}
|
||||||
for _, c := range ctrs {
|
for _, c := range ctrs {
|
||||||
report := entities.StopReport{Id: c.ID}
|
report := entities.StopReport{Id: c.ID}
|
||||||
report.Err = containers.Stop(ic.ClientCxt, c.ID, &options.Timeout)
|
if err = containers.Stop(ic.ClientCxt, c.ID, &options.Timeout); err != nil {
|
||||||
|
// These first two are considered non-fatal under the right conditions
|
||||||
|
if errors.Cause(err).Error() == define.ErrCtrStopped.Error() {
|
||||||
|
logrus.Debugf("Container %s is already stopped", c.ID)
|
||||||
|
reports = append(reports, &report)
|
||||||
|
continue
|
||||||
|
} else if options.All && errors.Cause(err).Error() == define.ErrCtrStateInvalid.Error() {
|
||||||
|
logrus.Debugf("Container %s is not running, could not stop", c.ID)
|
||||||
|
reports = append(reports, &report)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// TODO we need to associate errors returned by http with common
|
// TODO we need to associate errors returned by http with common
|
||||||
// define.errors so that we can equity tests. this will allow output
|
// define.errors so that we can equity tests. this will allow output
|
||||||
// to be the same as the native client
|
// to be the same as the native client
|
||||||
|
report.Err = err
|
||||||
|
reports = append(reports, &report)
|
||||||
|
continue
|
||||||
|
}
|
||||||
reports = append(reports, &report)
|
reports = append(reports, &report)
|
||||||
}
|
}
|
||||||
return reports, nil
|
return reports, nil
|
||||||
|
@ -217,7 +217,6 @@ var _ = Describe("Podman stop", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("podman stop all containers with one created", func() {
|
It("podman stop all containers with one created", func() {
|
||||||
Skip(v2remotefail)
|
|
||||||
session := podmanTest.RunTopContainer("test1")
|
session := podmanTest.RunTopContainer("test1")
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session.ExitCode()).To(Equal(0))
|
Expect(session.ExitCode()).To(Equal(0))
|
||||||
|
Reference in New Issue
Block a user