summaryrefslogtreecommitdiff
path: root/libnetwork/networkdb
Commit message (Collapse)AuthorAgeFilesLines
* libnet/networkdb: fix nil-dereference panic in testCory Snider2023-02-231-1/+4
| | | | Signed-off-by: Cory Snider <csnider@mirantis.com>
* Upgrade to golangci-lint v1.51.2Cory Snider2023-02-221-1/+1
| | | | Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnet/networkdb: use atomics for stats countersCory Snider2023-02-104-16/+18
| | | | | | | | The per-network statistics counters are loaded and incremented without any concurrency control. Use atomic integers to prevent data races without having to add any synchronization. Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork/networkdb: make go test -race ./libnetwork/networkdb passTibor Vass2023-02-101-14/+21
| | | | | | Signed-off-by: Tibor Vass <teabee89@gmail.com> Co-authored-by: Cory Snider <csnider@mirantis.com> Signed-off-by: Cory Snider <csnider@mirantis.com>
* libnetwork: use go-immutable-radix instead of radixTibor Vass2022-11-302-25/+26
| | | | | | | | | | | | | | | | | | This commit allows to remove dependency on the mutable version armon/go-radix. The go-immutable-radix package is better maintained. It is likely that a bit more memory will be used when using the immutable version, though discarded nodes are being reused in a pool. These changes happen when networks are added/removed or nodes come and go in a cluster, so we are still talking about a relatively low frequency event. The major changes compared to the old radix are when modifying (insert or delete) a tree, and those are pretty self-contained: we replace the entire immutable tree under a lock. Signed-off-by: Tibor Vass <teabee89@gmail.com>
* libnetwork: use strconv instead of fmt.Sprintf()Sebastiaan van Stijn2022-10-081-11/+11
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork: fix empty-lines (revive)Sebastiaan van Stijn2022-09-261-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libnetwork/etchosts/etchosts_test.go:167:54: empty-lines: extra empty line at the end of a block (revive) libnetwork/osl/route_linux.go:185:74: empty-lines: extra empty line at the start of a block (revive) libnetwork/osl/sandbox_linux_test.go:323:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/bitseq/sequence.go:412:48: empty-lines: extra empty line at the start of a block (revive) libnetwork/datastore/datastore_test.go:67:46: empty-lines: extra empty line at the end of a block (revive) libnetwork/datastore/mock_store.go:34:60: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/firewalld.go:202:44: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/firewalld_test.go:76:36: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/iptables.go:256:67: empty-lines: extra empty line at the end of a block (revive) libnetwork/iptables/iptables.go:303:128: empty-lines: extra empty line at the start of a block (revive) libnetwork/networkdb/cluster.go:183:72: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipams/null/null_test.go:44:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/macvlan/macvlan_store.go:45:52: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipam/allocator_test.go:1058:39: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/bridge/port_mapping.go:88:111: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/link.go:26:90: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/setup_ipv6_test.go:17:34: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/bridge/setup_ip_tables.go:392:4: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/bridge/bridge.go:804:50: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/ov_serf.go:183:29: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/ov_utils.go:81:64: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/overlay/peerdb.go:172:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:209:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:344:89: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/peerdb.go:436:63: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/overlay.go:183:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/drivers/overlay/encryption.go:69:28: empty-lines: extra empty line at the end of a block (revive) libnetwork/drivers/overlay/ov_network.go:563:81: empty-lines: extra empty line at the start of a block (revive) libnetwork/default_gateway.go:32:43: empty-lines: extra empty line at the start of a block (revive) libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the start of a block (revive) libnetwork/service_common.go:184:64: empty-lines: extra empty line at the end of a block (revive) libnetwork/endpoint.go:161:55: empty-lines: extra empty line at the end of a block (revive) libnetwork/store.go:320:33: empty-lines: extra empty line at the end of a block (revive) libnetwork/store_linux_test.go:11:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/sandbox.go:571:36: empty-lines: extra empty line at the start of a block (revive) libnetwork/service_common.go:317:246: empty-lines: extra empty line at the start of a block (revive) libnetwork/endpoint.go:550:17: empty-lines: extra empty line at the end of a block (revive) libnetwork/sandbox_dns_unix.go:213:106: empty-lines: extra empty line at the start of a block (revive) libnetwork/controller.go:676:85: empty-lines: extra empty line at the end of a block (revive) libnetwork/agent.go:876:60: empty-lines: extra empty line at the end of a block (revive) libnetwork/resolver.go:324:69: empty-lines: extra empty line at the end of a block (revive) libnetwork/network.go:1153:92: empty-lines: extra empty line at the end of a block (revive) libnetwork/network.go:1955:67: empty-lines: extra empty line at the start of a block (revive) libnetwork/network.go:2235:9: empty-lines: extra empty line at the start of a block (revive) libnetwork/libnetwork_internal_test.go:336:26: empty-lines: extra empty line at the start of a block (revive) libnetwork/resolver_test.go:76:35: empty-lines: extra empty line at the end of a block (revive) libnetwork/libnetwork_test.go:303:38: empty-lines: extra empty line at the end of a block (revive) libnetwork/libnetwork_test.go:985:46: empty-lines: extra empty line at the end of a block (revive) libnetwork/ipam/allocator_test.go:1263:37: empty-lines: extra empty line at the start of a block (revive) libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the end of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* linting: suppress false positive for G404 (gosec)Sebastiaan van Stijn2022-09-041-1/+1
| | | | | | | | | | The linter falsely detects this as using "math/rand": libnetwork/networkdb/cluster.go:721:14: G404: Use of weak random number generator (math/rand instead of crypto/rand) (gosec) val, err := rand.Int(rand.Reader, big.NewInt(int64(n))) ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork: refactor networkdb test implementationCory Snider2022-07-251-40/+31
| | | | | | | Leverage higher-order functions to DRY the polling checks in TestNetworkDBNodeJoinLeaveIteration. Signed-off-by: Cory Snider <csnider@mirantis.com>
* Test: wait for network changes in TestNetworkDBNodeJoinLeaveIterationDavid Wang2022-07-211-18/+41
| | | | | | | | | | | | | | In network node change test, the expected behavior is focused on how many nodes left in networkDB, besides timing issues, things would also go tricky for a leave-then-join sequence, if the check (counting the nodes) happened before the first "leave" event, then the testcase actually miss its target and report PASS without verifying its final result; if the check happened after the 'leave' event, but before the 'join' event, the test would report FAIL unnecessary; This code change would check both the db changes and the node count, it would report PASS only when networkdb has indeed changed and the node count is expected. Signed-off-by: David Wang <00107082@163.com>
* gofmt GoDoc comments with go1.19Sebastiaan van Stijn2022-07-081-10/+11
| | | | | | | | Older versions of Go don't format comments, so committing this as a separate commit, so that we can already make these changes before we upgrade to Go 1.19. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* fix typo (cluser -> cluster)Sebastiaan van Stijn2022-06-271-1/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork/networkdb: remove some redundant fmt.Sprintf()'sSebastiaan van Stijn2022-02-152-4/+4
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fix grammar for "does not exist"frobnicaty2021-12-031-2/+2
| | | | | | as opposed to "does not exists" Signed-off-by: frobnicaty <92033765+frobnicaty@users.noreply.github.com>
* refactor: move from io/ioutil to io and os packageEng Zer Jun2021-08-271-2/+1
| | | | | | | | The io/ioutil package has been deprecated in Go 1.16. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* Update to Go 1.17.0, and gofmt with Go 1.17Sebastiaan van Stijn2021-08-241-1/+3
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork: remove unused "testutils" importsSebastiaan van Stijn2021-08-181-3/+0
| | | | | | | Perhaps the testutils package in the past had an `init()` function to set up specific things, but it no longer has. so these imports were doing nothing. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* libnetwork/networkdb: consistently wait for nodes in testsRoman Volosatovs2021-08-011-13/+2
| | | | | | Use `verifyNetworkExistence` like it was done in 2837fba75f5ee7e57c167af4e70569adaf59377a Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
* libnetwork: wait until t.Deadline() instead of hardcoded valueRoman Volosatovs2021-08-011-2/+10
| | | | Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
* libnetwork: ensure all nodes are available in testsRoman Volosatovs2021-07-121-12/+4
| | | | | | | | | | | | | | `github.com/hashicorp/memberlist` update caused `TestNetworkDBCRUDTableEntries` to occasionally fail, because the test would try to check whether an entry write is propagated to all nodes, but it would not wait for all nodes to be available before performing the write. It could be that the failure is caused simply by improved performance of the dependency - it could also be that some connectivity guarantee the test depended on is not provided by the dependency anymore. The same fix is applied to `TestNetworkDBNodeJoinLeaveIteration` due to same issue. Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
* libnetwork: make rejoin intervals configurableRoman Volosatovs2021-07-123-20/+45
| | | | | | | | This allows the rejoin intervals to be chosen according to the context within which the component is used, and, in particular, this allows lower intervals to be used within TestNetworkDBIslands test. Signed-off-by: Roman Volosatovs <roman.volosatovs@docker.com>
* Fix gosec complaints in libnetworkBrian Goff2021-06-251-1/+1
| | | | | | | | | These were purposefully ignored before but this goes ahead and "fixes" most of them. Note that none of the things gosec flagged are problematic, just quieting the linter here. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* networkdb: mark test-helpers as t.Helper()Sebastiaan van Stijn2021-06-091-17/+24
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fix flakey test TestNetworkDBIslandsBrian Goff2021-06-021-11/+37
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Skip libnetwork integration tests on WindowsBrian Goff2021-06-021-2/+1
| | | | | | | 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>
* Fixup libnetwork lint errorsBrian Goff2021-06-013-15/+15
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix libnetwork importsBrian Goff2021-06-013-5/+5
| | | | | | | | | After moving libnetwork to this repo, we need to update all the import paths for libnetwork to point to docker/docker/libnetwork instead of docker/libnetwork. This change implements that. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* vendor: gotest.tools v3.0.2Sebastiaan van Stijn2020-09-121-3/+3
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* regenerate protobufs with debian busterSebastiaan van Stijn2020-02-261-14/+14
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Fix flaky NetworkDB testsArko Dasgupta2019-10-041-25/+42
| | | | | | | | | | | | | | | | | | | | | | Fixed these tests : 1.TestNetworkDBIslands Addresses : https://github.com/docker/libnetwork/issues/2402 2.TestNetworkDBCRUDMediumCluster Addresses : https://github.com/docker/libnetwork/issues/2401 By : 1. Importing gotest.tools/poll to use poll.WaitOn Above function can be used to check a condition at regular intervals until a timeout is reached 2. Replacing Sleep with poll.WaitOn 2. Adding closeNetworkDBInstances to close remaining DBs Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
* Merge pull request #2238 from talex5/networkdb-docsFlavio Crisciani2019-03-141-1/+1
|\ | | | | Add NetworkDB docs
| * Add NetworkDB docsThomas Leonard2018-08-081-1/+1
| | | | | | | | | | | | This is based on reading the code in the `networkdb` directory. Signed-off-by: Thomas Leonard <thomas.leonard@docker.com>
* | Fix possible nil pointer exceptionFlavio Crisciani2019-01-221-1/+6
| | | | | | | | | | | | | | | | It is possible that the node is not yet present in the node list map. In this case just print a warning and return. The next iteration would be fine Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* | fix error when make lintLei Gong2018-09-081-2/+2
|/ | | | | | | | | | | ``` make lint networkdb/networkdb_test.go:88:2: should replace t.Error(fmt.Sprintf(...)) with t.Errorf(...) networkdb/networkdb_test.go:136:2: should replace t.Error(fmt.Sprintf(...)) with t.Errorf(...) make: *** [lint] Error 1 ``` Signed-off-by: Lei Gong <lgong@alauda.io>
* Create internal directoryFlavio Crisciani2018-07-161-12/+12
| | | | | | | Internal directory is designed to contain libraries that are exclusively used by this project Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* Spelling fixesJosh Soref2018-07-124-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * addresses * assigned * at least * attachments * auxiliary * available * cleanup * communicate * communications * configuration * connection * connectivity * destination * encountered * endpoint * example * existing * expansion * expected * external * forwarded * gateway * implementations * implemented * initialize * internally * loses * message * network * occurred * operational * origin * overlapping * reaper * redirector * release * representation * resolver * retrieve * returns * sanbdox * sequence * succesful * synchronizing * update * validates Signed-off-by: Josh Soref <jsoref@gmail.com>
* Migrate to gotest.tools :)Vincent Demeester2018-07-061-147/+147
| | | | Signed-off-by: Vincent Demeester <vincent@sbr.pm>
* Merge pull request #2216 from fcrisciani/netdb-qlen-issueFlavio Crisciani2018-07-055-17/+90
|\ | | | | NetworkDB qlen optimization
| * Optimize networkDB queueFlavio Crisciani2018-07-024-17/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added some optimizations to reduce the messages in the queue: 1) on join network the node execute a tcp sync with all the nodes that it is aware part of the specific network. During this time before the node was redistributing all the entries. This meant that if the network had 10K entries the queue of the joining node will jump to 10K. The fix adds a flag on the network that would avoid to insert any entry in the queue till the sync happens. Note that right now the flag is set in a best effort way, there is no real check if at least one of the nodes succeed. 2) limit the number of messages to redistribute coming from a TCP sync. Introduced a threshold that limit the number of messages that are propagated, this will disable this optimization in case of heavy load. Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
| * Enhance testing infraFlavio Crisciani2018-07-021-0/+39
| | | | | | | | | | | | | | Allow to write and delete X number of entries Allow to query the queue length Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* | Use fmt precision to limit string lengthChris Telfer2018-07-051-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous code used string slices to limit the length of certain fields like endpoint or sandbox IDs. This assumes that these strings are at least as long as the slice length. Unfortunately, some sandbox IDs can be smaller than 7 characters. This fix addresses this issue by systematically converting format string calls that were taking fixed-slice arguments to use a precision specifier in the string format itself. From the golang fmt package documentation: For strings, byte slices and byte arrays, however, precision limits the length of the input to be formatted (not the size of the output), truncating if necessary. Normally it is measured in runes, but for these types when formatted with the %x or %X format it is measured in bytes. This nicely fits the desired behavior: it will limit the number of runes considered for string interpolation to the precision value. Signed-off-by: Chris Telfer <ctelfer@docker.com>
* | Allows to set generic knobs on the SandboxFlavio Crisciani2018-06-281-5/+4
|/ | | | | | | | Refactor the ostweaks file to allows a more easy reuse Add a method on the osl.Sandbox interface to allow setting knobs on the sandbox Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* Merge pull request #2200 from fcrisciani/networkdb-retryFlavio Crisciani2018-06-283-17/+91
|\ | | | | Adjust corner case for reconnect logic
| * Adjust corner case for reconnect logicFlavio Crisciani2018-06-213-17/+91
| | | | | | | | | | | | | | | | | | | | Previous logic was not accounting that each node is in the node list so the bootstrap nodes won't retry to reconnect because they will always find themselves in the node map Added test that validate the gossip island condition Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* | networkdb, drivers: Regenerate protocol buffersEuan Harris2018-06-221-82/+64
|/ | | | | | | | | | | agent.pb.go is unchanged, but the files in networkdb and drivers are slightly different when regenerated using the current versions of protoc and gogoproto. This is probably because agent.pb.go was last regenerated quite recently, in February 2018, whereas networkdb.pb.go and overlay/overlay.pb.go were last changed in 2017, and windows/overlay/overlay.pb.go was last changed in 2016. Signed-off-by: Euan Harris <euan.harris@docker.com>
* Further makefile cleanupFlavio Crisciani2018-06-161-1/+1
| | | | | | | - cleaned the make check - local build do not require context Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
* Merge pull request #2134 from dani-docker/esc-532Flavio Crisciani2018-04-233-26/+57
|\ | | | | Adding a recovery mechanism for a split gossip cluster
| * Adding a recovery mechanism for a split gossip clusterDani Louca2018-04-233-26/+57
| | | | | | | | Signed-off-by: Dani Louca <dani.louca@docker.com>
* | networkdb: Use write lock in handleNodeEventBrian Goff2018-04-111-2/+2
|/ | | | | | | | | `handleNodeEvent` is calling `changeNodeState` which writes to various maps on the ndb object. Using a write lock prevents a panic on concurrent read/write access on these maps. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix README flag and expose orphan network peersFlavio Crisciani2018-03-232-2/+6
| | | | | | | - Readme example was using wrong flag - Network peers were not exposed properly Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>