libnetwork: stop caching global netlink handle
The global netlink handle ns.NlHandle() is indirectly cached for the life of the process by the netutils.CheckRouteOverlaps() function. This caching behaviour is a problem for the libnetwork unit tests as the global netlink handle changes every time testutils.SetupTestOSContext() is called, i.e. at the start of nearly every test case. Route overlaps can be checked for in the wrong network namespace, causing spurious test failures e.g. when running the same test twice in a row with -count=2. Stop the netlink handle from being cached by shadowing the package-scope variable with a function-scoped one. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
d0096bba21
commit
1b64f2e28b
1 changed files with 1 additions and 0 deletions
|
@ -24,6 +24,7 @@ var (
|
|||
|
||||
// CheckRouteOverlaps checks whether the passed network overlaps with any existing routes
|
||||
func CheckRouteOverlaps(toCheck *net.IPNet) error {
|
||||
networkGetRoutesFct := networkGetRoutesFct
|
||||
if networkGetRoutesFct == nil {
|
||||
networkGetRoutesFct = ns.NlHandle().RouteList
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue