summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-12-19 06:18:21 -0500
committerGitHub <noreply@github.com>2021-12-19 06:18:21 -0500
commitf45070ee0e63ea26e475e618ff32a498096fa561 (patch)
tree4419895229b9a8dc848f2ee11f845d416b2b41c2 /libpod
parent65efd55d416e84a953b11211b2c80783ff632379 (diff)
parent12d762f8ee288164cdb1a8390520d88c4c5eb1bc (diff)
downloadpodman-f45070ee0e63ea26e475e618ff32a498096fa561.tar.gz
podman-f45070ee0e63ea26e475e618ff32a498096fa561.tar.bz2
podman-f45070ee0e63ea26e475e618ff32a498096fa561.zip
Merge pull request #12626 from vrothberg/may-the-force-be-with-removal
image rm: allow for force-remove infra images
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_img.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index 52ac0d4d7..bf0fc4585 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -36,10 +36,21 @@ func (r *Runtime) RemoveContainersForImageCallback(ctx context.Context) libimage
return err
}
for _, ctr := range ctrs {
- if ctr.config.RootfsImageID == imageID {
- var timeout *uint
+ if ctr.config.RootfsImageID != imageID {
+ continue
+ }
+ var timeout *uint
+ if ctr.config.IsInfra {
+ pod, err := r.state.Pod(ctr.config.Pod)
+ if err != nil {
+ return errors.Wrapf(err, "container %s is in pod %s, but pod cannot be retrieved", ctr.ID(), pod.ID())
+ }
+ if err := r.removePod(ctx, pod, true, true, timeout); err != nil {
+ return errors.Wrapf(err, "removing image %s: container %s using image could not be removed", imageID, ctr.ID())
+ }
+ } else {
if err := r.removeContainer(ctx, ctr, true, false, false, timeout); err != nil {
- return errors.Wrapf(err, "error removing image %s: container %s using image could not be removed", imageID, ctr.ID())
+ return errors.Wrapf(err, "removing image %s: container %s using image could not be removed", imageID, ctr.ID())
}
}
}