summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-01-13 18:40:52 +0100
committerGitHub <noreply@github.com>2022-01-13 18:40:52 +0100
commit48e63975aac7f13048a4b2e426e36d2c81828d6d (patch)
tree580f2d30341d45c087c4d5a47392a325d97f5ce1 /libpod
parenteeb76db0fd0dc2a1115c2f2ad12c82eadbc62509 (diff)
parenta4cef543504600db95453aa863b97ed82c833d41 (diff)
downloadpodman-48e63975aac7f13048a4b2e426e36d2c81828d6d.tar.gz
podman-48e63975aac7f13048a4b2e426e36d2c81828d6d.tar.bz2
podman-48e63975aac7f13048a4b2e426e36d2c81828d6d.zip
Merge pull request #12826 from vrothberg/force-rm-pod
podman container rm: remove pod
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_ctr.go25
1 files changed, 23 insertions, 2 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index a56c21e75..4475119fb 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -915,9 +915,30 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
return id, cleanupErr
}
-// RemoveDepend removes all dependencies for a container
+// RemoveDepend removes all dependencies for a container.
+// If the container is an infra container, the entire pod gets removed.
func (r *Runtime) RemoveDepend(ctx context.Context, rmCtr *Container, force bool, removeVolume bool, timeout *uint) ([]*reports.RmReport, error) {
+ logrus.Debugf("Removing container %s and all dependent containers", rmCtr.ID())
rmReports := make([]*reports.RmReport, 0)
+ if rmCtr.IsInfra() {
+ pod, err := r.GetPod(rmCtr.PodID())
+ if err != nil {
+ return nil, err
+ }
+ logrus.Debugf("Removing pod %s: depends on infra container %s", pod.ID(), rmCtr.ID())
+ podContainerIDS, err := pod.AllContainersByID()
+ if err != nil {
+ return nil, err
+ }
+ if err := r.RemovePod(ctx, pod, true, force, timeout); err != nil {
+ return nil, err
+ }
+ for _, cID := range podContainerIDS {
+ rmReports = append(rmReports, &reports.RmReport{Id: cID})
+ }
+ return rmReports, nil
+ }
+
deps, err := r.state.ContainerInUse(rmCtr)
if err != nil {
if err == define.ErrCtrRemoved {
@@ -940,9 +961,9 @@ func (r *Runtime) RemoveDepend(ctx context.Context, rmCtr *Container, force bool
}
rmReports = append(rmReports, reports...)
}
+
report := reports.RmReport{Id: rmCtr.ID()}
report.Err = r.removeContainer(ctx, rmCtr, force, removeVolume, false, timeout)
-
return append(rmReports, &report), nil
}