summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-11-18 19:05:32 +0100
committerPaul Holzinger <pholzing@redhat.com>2021-11-22 17:49:55 +0100
commit044edbb9c9e798e1848682fa0e5389791296f2cb (patch)
tree5ee9a2535c01b52844cf83f5796a7219028ba25b
parentbfc929efc44cc9255406ed6c2abec1b8a4f36dab (diff)
downloadpodman-044edbb9c9e798e1848682fa0e5389791296f2cb.tar.gz
podman-044edbb9c9e798e1848682fa0e5389791296f2cb.tar.bz2
podman-044edbb9c9e798e1848682fa0e5389791296f2cb.zip
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 <pholzing@redhat.com>
-rw-r--r--libpod/network/netavark/run.go8
-rw-r--r--pkg/specgenutil/util.go1
2 files changed, 9 insertions, 0 deletions
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))
diff --git a/pkg/specgenutil/util.go b/pkg/specgenutil/util.go
index 534374e71..6b564c60e 100644
--- a/pkg/specgenutil/util.go
+++ b/pkg/specgenutil/util.go
@@ -295,6 +295,7 @@ func CreateExitCommandArgs(storageConfig storageTypes.StoreOptions, config *conf
"--cgroup-manager", config.Engine.CgroupManager,
"--tmpdir", config.Engine.TmpDir,
"--cni-config-dir", config.Network.NetworkConfigDir,
+ "--network-backend", config.Network.NetworkBackend,
}
if config.Engine.OCIRuntime != "" {
command = append(command, []string{"--runtime", config.Engine.OCIRuntime}...)