Commit graph

15 commits

Author SHA1 Message Date
Cory Snider
d21d0884ae libnetwork: share a single datastore with drivers
The bbolt library wants exclusive access to the boltdb file and uses
file locking to assure that is the case. The controller and each network
driver that needs persistent storage instantiates its own unique
datastore instance, backed by the same boltdb file. The boltdb kvstore
implementation works around multiple access to the same boltdb file by
aggressively closing the boltdb file between each transaction. This is
very inefficient. Have the controller pass its datastore instance into
the drivers and enable the PersistConnection option to disable closing
the boltdb between transactions.

Set data-dir in unit tests which instantiate libnetwork controllers so
they don't hang trying to lock the default boltdb database file.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-01-31 21:08:34 -05:00
Albin Kerouanton
492c09276d
tests: Move libnetwork/testutils to internal/testutils/netnsutils
We don't want to maintain backward compatibility for this package, so
better make it an internal.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-07-26 21:06:36 +02:00
Sebastiaan van Stijn
6025938ee9
Merge pull request #45987 from thaJeztah/cleanup_iptables_the_sequel
libnetwork/iptables: some cleanups and refactoring: the sequel
2023-07-19 14:38:12 +02:00
Sebastiaan van Stijn
82bb3d8d2b
libnetwork: TestUserChain: use assert.Check and is.ErrorContains
Don't fail early if we can still test more, and be slightly more strict
in what error we're looking for.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 09:53:13 +02:00
Sebastiaan van Stijn
4e709e75da
libnetwork: TestUserChain: re-use IPTables instances
The test already creates instances for each ip-version, so let's
re-use them. While changing, also use assert.Check to not fail early.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 09:53:13 +02:00
Sebastiaan van Stijn
c471255153
libnetwork: TestUserChain: don't manually manipulate Controller.cfg.DriverCfg
New() allows for driver-options to be passed using the config.OptionDriverConfig.
Update the test to not manually mutate the controller's configuration after
creating.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 09:53:10 +02:00
Sebastiaan van Stijn
ad0c928ab5
libnetwork/iptables: resetIptables(): don't pass empty table name
Don't depend on a default being set, but explicitly pass the table.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-16 20:37:05 +02:00
Albin Kerouanton
ffd75c2e0c
libnetwork: Support IPv6 in arrangeUserFilterRule() (redux)
This reapplies commit 2d397beb00.

Fixes #44451.

Co-authored-by: Bjorn Neergaard <bneergaard@mirantis.com>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
2023-01-14 19:11:44 -07:00
Bjorn Neergaard
17723691e5
Revert "libnetwork: Support IPv6 in arrangeUserFilterRule()"
This reverts commit 2d397beb00.

moby#44706 and moby#44805 were both merged, and both refactored the same
file. The combination broke the build, and was not detected in CI as
only the combination of the two, applied to the same parent commit,
caused the failure.

moby#44706 should be carried forward, based on the current master, in
order to resolve this conflict.

Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
2023-01-14 15:31:56 -07:00
Bjorn Neergaard
803c21f4b2
Merge pull request #44706 from akerouanton/fix-44451
libnetwork: Support IPv6 in arrangeUserFilterRule()
2023-01-14 15:18:01 -07:00
Cory Snider
f96b9bf761 libnetwork: return concrete-typed *Controller
libnetwork.NetworkController is an interface with a single
implementation.

https://github.com/golang/go/wiki/CodeReviewComments#interfaces

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-01-13 14:09:37 -05:00
Albin Kerouanton
2d397beb00
libnetwork: Support IPv6 in arrangeUserFilterRule()
Fixes #44451.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-01-09 17:18:28 +01:00
Cory Snider
32ace57479 libnetwork_test: isolate tests from each other
Reusing the same "OS context" (read: network namespace) and
NetworkController across multiple tests risks tests interfering with
each other, or worse: _depending on_ other tests to set up
preconditions. Construct a new controller for every test which needs
one, and run every test which mutates or inspects the host environment
in a fresh OS context.

The only outlier is runParallelTests. It is the only remaining test
implementation which references the "global" package-scoped controller,
so the global controller instance is effectively private to that one
test.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2022-11-08 17:56:45 -05:00
Sebastiaan van Stijn
528428919e
libnetwork/config: merge DaemonCfg into Config
It was unclear what the distinction was between these configuration
structs, so merging them to simplify.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Brian Goff
b3c883bb2f Skip libnetwork integration tests on Windows
Most of these tests are making use of the bridge network and do not work
on Windows.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-02 16:53:29 +00:00