1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
From: Valentin Rothberg <vrothberg@redhat.com>
Date: Mon, 6 Feb 2023 13:52:40 +0100
Subject: [PATCH] network ls: handle removed container
Handle a race condition in the REST API when listing networks.
In between listing all containers and inspecting them, they may have
already been removed, so handle this case gracefully.
[NO NEW TESTS NEEDED] as it's a race condition.
Fixes: #17341
Forwarded: not-needed
Origin: upstream, https://github.com/containers/podman/commit/ced934284058232c1c3d76956786106d64511f89
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go
index 704af4b0e427..587da14361eb 100644
--- a/pkg/api/handlers/compat/networks.go
+++ b/pkg/api/handlers/compat/networks.go
@@ -74,6 +74,9 @@ func convertLibpodNetworktoDockerNetwork(runtime *libpod.Runtime, network *netty
for _, con := range cons {
data, err := con.Inspect(false)
if err != nil {
+ if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved) {
+ continue
+ }
return nil, err
}
if netData, ok := data.NetworkSettings.Networks[network.Name]; ok {
|