diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-01-21 09:49:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 09:49:15 -0500 |
commit | d102d02eb1cd135d877d946249a4fa1769ba17d0 (patch) | |
tree | 31f5f687761f012a12d596a99c5e5656ffa89a42 /libpod | |
parent | 7d297ddbdabe81b94184f2b2fe095f42389ddfa6 (diff) | |
parent | 836fa4c493c3809da4bbcbbec0bf5ceb954e7410 (diff) | |
download | podman-d102d02eb1cd135d877d946249a4fa1769ba17d0.tar.gz podman-d102d02eb1cd135d877d946249a4fa1769ba17d0.tar.bz2 podman-d102d02eb1cd135d877d946249a4fa1769ba17d0.zip |
Merge pull request #9046 from Luap99/fix-network-tests
Fix e2e network test flakes
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/network/create.go | 2 | ||||
-rw-r--r-- | libpod/network/lock.go | 13 | ||||
-rw-r--r-- | libpod/network/network.go | 3 |
3 files changed, 13 insertions, 5 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go index 094fbe349..e7f65358b 100644 --- a/libpod/network/create.go +++ b/libpod/network/create.go @@ -23,7 +23,7 @@ func Create(name string, options entities.NetworkCreateOptions, runtimeConfig *c return nil, err } // Acquire a lock for CNI - l, err := acquireCNILock(filepath.Join(runtimeConfig.Engine.TmpDir, LockFileName)) + l, err := acquireCNILock(runtimeConfig) if err != nil { return nil, err } diff --git a/libpod/network/lock.go b/libpod/network/lock.go index 0395359eb..037f41efa 100644 --- a/libpod/network/lock.go +++ b/libpod/network/lock.go @@ -1,6 +1,10 @@ package network import ( + "os" + "path/filepath" + + "github.com/containers/common/pkg/config" "github.com/containers/storage" ) @@ -8,8 +12,13 @@ import ( // delete cases to avoid unwanted collisions in network names. // TODO this uses a file lock and should be converted to shared memory // when we have a more general shared memory lock in libpod -func acquireCNILock(lockPath string) (*CNILock, error) { - l, err := storage.GetLockfile(lockPath) +func acquireCNILock(config *config.Config) (*CNILock, error) { + cniDir := GetCNIConfDir(config) + err := os.MkdirAll(cniDir, 0755) + if err != nil { + return nil, err + } + l, err := storage.GetLockfile(filepath.Join(cniDir, LockFileName)) if err != nil { return nil, err } diff --git a/libpod/network/network.go b/libpod/network/network.go index 89f0b67ac..0fb878b18 100644 --- a/libpod/network/network.go +++ b/libpod/network/network.go @@ -6,7 +6,6 @@ import ( "encoding/json" "net" "os" - "path/filepath" "github.com/containernetworking/cni/pkg/types" "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/allocator" @@ -172,7 +171,7 @@ func ValidateUserNetworkIsAvailable(config *config.Config, userNet *net.IPNet) e // RemoveNetwork removes a given network by name. If the network has container associated with it, that // must be handled outside the context of this. func RemoveNetwork(config *config.Config, name string) error { - l, err := acquireCNILock(filepath.Join(config.Engine.TmpDir, LockFileName)) + l, err := acquireCNILock(config) if err != nil { return err } |