From 6c8c70c0152beea9bc99bd5dfdf5b262a271deee Mon Sep 17 00:00:00 2001 From: Valentin Rothberg 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 Signed-off-by: Valentin Rothberg --- pkg/api/handlers/compat/networks.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 704af4b0e4..587da14361 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 {