summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-09-27 23:11:31 +0200
committerPaul Holzinger <paul.holzinger@web.de>2020-09-28 10:41:25 +0200
commit393120c13567ef1b6d42bac357eddf44cfa74d16 (patch)
tree990156ecca0b2fee35f942f973b9216a6d117cf4 /pkg/domain/infra/abi
parent03d01abec6d028e9d5f60615b0451e42d0611d1d (diff)
downloadpodman-393120c13567ef1b6d42bac357eddf44cfa74d16.tar.gz
podman-393120c13567ef1b6d42bac357eddf44cfa74d16.tar.bz2
podman-393120c13567ef1b6d42bac357eddf44cfa74d16.zip
Fix podman network rm --force when network is used by a pod
I added a test to prevent a future regression. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r--pkg/domain/infra/abi/network.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go
index 807e4b272..053be6528 100644
--- a/pkg/domain/infra/abi/network.go
+++ b/pkg/domain/infra/abi/network.go
@@ -82,12 +82,21 @@ func (ic *ContainerEngine) NetworkRm(ctx context.Context, namesOrIds []string, o
// We need to iterate containers looking to see if they belong to the given network
for _, c := range containers {
if util.StringInSlice(name, c.Config().Networks) {
- // if user passes force, we nuke containers
+ // if user passes force, we nuke containers and pods
if !options.Force {
// Without the force option, we return an error
- return reports, errors.Errorf("%q has associated containers with it. Use -f to forcibly delete containers", name)
+ return reports, errors.Errorf("%q has associated containers with it. Use -f to forcibly delete containers and pods", name)
}
- if err := ic.Libpod.RemoveContainer(ctx, c, true, true); err != nil {
+ if c.IsInfra() {
+ // if we have a infra container we need to remove the pod
+ pod, err := ic.Libpod.GetPod(c.PodID())
+ if err != nil {
+ return reports, err
+ }
+ if err := ic.Libpod.RemovePod(ctx, pod, true, true); err != nil {
+ return reports, err
+ }
+ } else if err := ic.Libpod.RemoveContainer(ctx, c, true, true); err != nil {
return reports, err
}
}