From 044edbb9c9e798e1848682fa0e5389791296f2cb Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Thu, 18 Nov 2021 19:05:32 +0100 Subject: Fix netavark error handling and teardown issue The return error was not returned by podman , instead a different error was created. Also make sure to free assigned ips on an error to not leak them. Lastly podman container cleanup uses the default network backend instead of the provided one, we need to add `--network-backend` to the exit command. [NO NEW TESTS NEEDED] Signed-off-by: Paul Holzinger --- libpod/network/netavark/run.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libpod/network') diff --git a/libpod/network/netavark/run.go b/libpod/network/netavark/run.go index 54917a981..0ac20daee 100644 --- a/libpod/network/netavark/run.go +++ b/libpod/network/netavark/run.go @@ -55,7 +55,15 @@ func (n *netavarkNetwork) Setup(namespacePath string, options types.SetupOptions result := map[string]types.StatusBlock{} err = n.execNetavark([]string{"setup", namespacePath}, netavarkOpts, &result) + if err != nil { + // lets dealloc ips to prevent leaking + if err := n.deallocIPs(&options.NetworkOptions); err != nil { + logrus.Error(err) + } + return nil, err + } + // make sure that the result makes sense if len(result) != len(options.Networks) { logrus.Errorf("unexpected netavark result: %v", result) return nil, fmt.Errorf("unexpected netavark result length, want (%d), got (%d) networks", len(options.Networks), len(result)) -- cgit v1.2.3-54-g00ecf