summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2021-08-04 18:45:14 +0000
committerGitHub <noreply@github.com>2021-08-04 18:45:14 +0000
commit9c2fc4b6228889ea850656468381a8be45f7e3cd (patch)
tree0fefde08a04349dc45336c9a5fcd4d748d23897c /pkg
parent77f8c6549ab1df393f613cc13e93e8dcec859614 (diff)
parent41f94a4dc1a6c426f2d05c440bc36a4e7b425809 (diff)
downloadpodman-9c2fc4b6228889ea850656468381a8be45f7e3cd.tar.gz
podman-9c2fc4b6228889ea850656468381a8be45f7e3cd.tar.bz2
podman-9c2fc4b6228889ea850656468381a8be45f7e3cd.zip
Merge pull request #11113 from rhatdan/unpause
Fix podman unpause to work like podman stop
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/containers.go15
-rw-r--r--pkg/domain/infra/tunnel/containers.go17
2 files changed, 29 insertions, 3 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index ddd768328..a74b65ab9 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -119,6 +119,10 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
report := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
for _, c := range ctrs {
err := c.Pause()
+ if err != nil && options.All && errors.Cause(err) == define.ErrCtrStateInvalid {
+ logrus.Debugf("Container %s is not running", c.ID())
+ continue
+ }
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
}
return report, nil
@@ -132,6 +136,10 @@ func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []st
report := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
for _, c := range ctrs {
err := c.Unpause()
+ if err != nil && options.All && errors.Cause(err) == define.ErrCtrStateInvalid {
+ logrus.Debugf("Container %s is not paused", c.ID())
+ continue
+ }
report = append(report, &entities.PauseUnpauseReport{Id: c.ID(), Err: err})
}
return report, nil
@@ -220,9 +228,14 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
}
reports := make([]*entities.KillReport, 0, len(ctrs))
for _, con := range ctrs {
+ err := con.Kill(uint(sig))
+ if options.All && errors.Cause(err) == define.ErrCtrStateInvalid {
+ logrus.Debugf("Container %s is not running", con.ID())
+ continue
+ }
reports = append(reports, &entities.KillReport{
Id: con.ID(),
- Err: con.Kill(uint(sig)),
+ Err: err,
RawInput: ctrMap[con.ID()],
})
}
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 3c2802165..b638bfe24 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -63,19 +63,27 @@ func (ic *ContainerEngine) ContainerPause(ctx context.Context, namesOrIds []stri
reports := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
for _, c := range ctrs {
err := containers.Pause(ic.ClientCtx, c.ID, nil)
+ if err != nil && options.All && errors.Cause(err).Error() == define.ErrCtrStateInvalid.Error() {
+ logrus.Debugf("Container %s is not running", c.ID)
+ continue
+ }
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
}
return reports, nil
}
func (ic *ContainerEngine) ContainerUnpause(ctx context.Context, namesOrIds []string, options entities.PauseUnPauseOptions) ([]*entities.PauseUnpauseReport, error) {
+ reports := []*entities.PauseUnpauseReport{}
ctrs, err := getContainersByContext(ic.ClientCtx, options.All, false, namesOrIds)
if err != nil {
return nil, err
}
- reports := make([]*entities.PauseUnpauseReport, 0, len(ctrs))
for _, c := range ctrs {
err := containers.Unpause(ic.ClientCtx, c.ID, nil)
+ if err != nil && options.All && errors.Cause(err).Error() == define.ErrCtrStateInvalid.Error() {
+ logrus.Debugf("Container %s is not paused", c.ID)
+ continue
+ }
reports = append(reports, &entities.PauseUnpauseReport{Id: c.ID, Err: err})
}
return reports, nil
@@ -136,9 +144,14 @@ func (ic *ContainerEngine) ContainerKill(ctx context.Context, namesOrIds []strin
options := new(containers.KillOptions).WithSignal(opts.Signal)
reports := make([]*entities.KillReport, 0, len(ctrs))
for _, c := range ctrs {
+ err := containers.Kill(ic.ClientCtx, c.ID, options)
+ if err != nil && opts.All && errors.Cause(err).Error() == define.ErrCtrStateInvalid.Error() {
+ logrus.Debugf("Container %s is not running", c.ID)
+ continue
+ }
reports = append(reports, &entities.KillReport{
Id: c.ID,
- Err: containers.Kill(ic.ClientCtx, c.ID, options),
+ Err: err,
RawInput: ctrMap[c.ID],
})
}