From 2bcc95257fcbb6d9d20c24c8bcb9de86f0362b15 Mon Sep 17 00:00:00 2001 From: Jakub Guzik Date: Fri, 5 Mar 2021 11:39:03 +0100 Subject: Fix for podman network rm (-f) workflow Signed-off-by: Jakub Guzik --- pkg/domain/infra/abi/network.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'pkg/domain/infra/abi') diff --git a/pkg/domain/infra/abi/network.go b/pkg/domain/infra/abi/network.go index 50a74032c..edde8ece6 100644 --- a/pkg/domain/infra/abi/network.go +++ b/pkg/domain/infra/abi/network.go @@ -96,7 +96,15 @@ 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) { + networks, _, err := c.Networks() + // if container vanished or network does not exist, go to next container + if errors.Is(err, define.ErrNoSuchNetwork) || errors.Is(err, define.ErrNoSuchCtr) { + continue + } + if err != nil { + return reports, err + } + if util.StringInSlice(name, networks) { // if user passes force, we nuke containers and pods if !options.Force { // Without the force option, we return an error -- cgit v1.2.3-54-g00ecf