Commit graph

66 commits

Author SHA1 Message Date
Sebastiaan van Stijn
745ba3ecbc
libnetwork: remove etcd-related code and tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:45:43 +01:00
Sebastiaan van Stijn
147173b099
libnetwork: remove consul-related code and tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:45:41 +01:00
Sebastiaan van Stijn
a7d0f3060a
libnetwork: remove zookeeper-related code and tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:28:30 +01:00
Brian Goff
3ad9549e70
Merge pull request #42545 from steffengy/master
libnetwork: processEndpointDelete: Fix deadlock between getSvcRecords and processEndpointDelete
2021-07-29 09:29:34 -07:00
Steffen Butzer
0c1a125644 libnetwork: processEndpointCreate: Fix deadlock between getSvcRecords and processEndpointCreate
References https://github.com/moby/moby/pull/42545

Signed-off-by: Steffen Butzer <steffen.butzer@outlook.com>
2021-06-29 08:07:14 +02:00
Steffen Butzer
7c97896747 libnetwork: processEndpointDelete: Fix deadlock between getSvcRecords and processEndpointDelete
We had some hosts with quite a bit of cycling containers that ocassionally causes docker daemons to lock up.
Most prominently `docker run` commands do not respond and nothing happens anymore.

Looking at the stack trace the following is at least likely sometimes a cause to that:
Two goroutines g0 and g1 can race against each other:
* (g0) 1. getSvcRecords is called and calls (*network).Lock()
       --> Network is locked.
* (g1) 2. processEndpointDelete is called, and calls (*controller).Lock()
       --> Controller is locked
* (g1) 3. processEndpointDelete tries (*network).ID() which calls (*network).Lock().
* (g0) 4. getSvcRecords calls (*controller).Lock().

3./4. are deadlocked against each other since the other goroutine holds the lock they need.

References b5dc370370/network.go

Signed-off-by: Steffen Butzer <steffen.butzer@outlook.com>
2021-06-22 16:05:20 +02:00
Brian Goff
4b981436fe Fixup libnetwork lint errors
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 23:48:32 +00:00
Brian Goff
a0a473125b Fix libnetwork imports
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>
2021-06-01 21:51:23 +00:00
Xinfeng Liu
0c8ffda2ab Fix 'failed to get network during CreateEndpoint'
Fix 'failed to get network during CreateEndpoint' during container starting.
Change the error type to `libnetwork.ErrNoSuchNetwork`, so `Start()` in `daemon/cluster/executor/container/controller.go` will recreate the network.

Signed-off-by: Xinfeng Liu <xinfeng.liu@gmail.com>
2020-06-01 17:16:07 +08:00
Sebastiaan van Stijn
07ed00102d store.getNetworksFromStore() remove unused error return
This function always returned `nil`, so we can remove the error
return, and update other functions that were handling errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-26 10:39:38 +02:00
Espen Suenson
a1ab732711 return immediately on error
Signed-off-by: Espen Suenson <mail@espensuenson.dk>
2019-09-24 10:58:08 +02:00
Espen Suenson
43a3151db2 Fixed getNetworkFromStore, which returned incorrect network information - notably, the 'resolver' field was empty.
This fixes https://github.com/moby/moby/issues/38901

Signed-off-by: Espen Suenson <mail@espensuenson.dk>
2019-09-11 21:09:23 +02:00
Chris Telfer
04bfc61497 Add option processing to network.Delete()
Change the Delete() method to take optional options and add
NetworkDeleteOptionRemoveLB as one such option.  This option allows
explicit removal of an ingress network along with its load-balancing
endpoint if there are no other endpoints in the network.  Prior to this,
the libnetwork client would have to manually search for and remove the
ingress load balancing endpoint from an ingress network.  This was, of
course, completely hacky.

This commit will require a slight modification in moby to make use of
the option when deleting the ingress network.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-06-28 12:08:12 -04:00
Pradip Dhara
4aab854d6d Addressing feedback from PR https://github.com/docker/libnetwork/pull/2011
Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2017-11-30 00:22:30 -08:00
Madhu Venugopal
2c8670b496 endpoint_cnt store updates should not create an object
endpoint_cnt object is created during network create and destroyed when
network is deleted. But the updateToStore function creates an object
when it is not present in the store. endpoint_cnt is a mutable object
and is updated during endpoint create and delete events. If endpoint
create or delete happens after the network is deleted, it can
incorrectly create an endpoint_cnt object in the store and that can
cause problems when the same network is created again later.

The fix is to not create the endpoint_cnt object when endpoint_cnt is
incremented or decremented

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-10-26 17:52:40 -07:00
Derek McGowan
710e0664c4 Update logrus to v1.0.1
Fix case sensitivity issue
Update docker and runc vendors

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-07 11:20:47 -07:00
Alessandro Boch
f626582c16 Do not reset network scope during store read
- Unless it is needed

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-05-15 12:05:56 -07:00
Alessandro Boch
254d082cc3 Add ConnectivityScope capability for network drivers along with scope network option
- It specifies whether the network driver can
  provide containers connectivity across hosts.
- As of now, the data scope of the driver was
  being overloaded with this notion.
- The driver scope information is still valid
  and it defines whether the data allocation
  of the network resources can be done globally
  or only locally.
- With the scope network option, user can now
  force a network as swarm scoped
  regardless of the driver data scope.
- In case the network is configured as swarm scoped,
  and the network driver is multihost capable,
  a network DB instance will be launched for it.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-05-12 17:16:34 -07:00
Alessandro Boch
25082206df Support configuration networks
- They are configuration-only networks which
  can be used to supply the configuration
  when creating regular networks.
- They do not get allocated and do net get plumbed.
  Drivers do not get to know about them.
- They can be removed, once no other network is
  using them.
- When user creates a network specifying a
  configuration network for the config, no
  other network specific configuration field
  is are accepted. User can only specify
  network operator fields (attachable, internal,...)
- They do not need to have a driver field, that
  field gets actually reset upon creation.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-05-11 11:37:18 -07:00
Akihiro Suda
79bf46fd79 improve error for getStore()
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-04-05 05:37:58 +00:00
Madhu Venugopal
71fff44c0b replace individual endpoint_cnt read from store with 1 bulk read
getNetworksFromStore reads networks and endpoint_cnt from the kvstores.
endpoint_cnt especially is read in a for-loop for each network and that
causes a lot of stress in poorly performing KV-Stores.
This fix eases the load on the kvstore by fetching all the endpoint_cnt
in a single read and the operation is performed on it.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-02-02 14:45:38 -08:00
Daehyeok Mun
7f473c779a Refactoring logrus import and formatting
This fix tries to fix logrus formatting by removing `f` from
`logrus.[Error|Warn|Debug|Fatal|Panic|Info]f` when formatting string
is not present.
Also fix import name to use original project name 'logrus' instead of
'log'

Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2016-11-08 12:42:41 -07:00
Jana Radhakrishnan
1f4c1cb75c Avoid k/v store endpoint update in swarm mode
Avoid the whole store endpoint update logic when running in swarm mode
and the endpoint is part of a global scope network. Currently there is
no store update that is happening for global scope networks in swarm
mode, but this code path will delete the svcRecords database when the
last endpoint on the network is removed which is something that is not
required.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-23 14:14:11 -07:00
Alessandro Boch
9328f1ea1e Refresh special drivers networks if present in store
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-14 21:50:58 -07:00
Alessandro Boch
bc6203bd0a Do not allow network creation if datastore is missing
- Earlier this was guaranteed by ipam driver intialization
  which was not creating a global address space if the
  global datastore was missing. Now that ipam address spaces
  can be initialized with no backing datastore, insert an
  explicit check in libnetwork, which should have been there
  regardless.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-12 16:36:54 -07:00
Jana Radhakrishnan
ffdceda255 Add service support
Add a notion of service in libnetwork so that a group of endpoints
which form a service can be treated as such so that service level
features can be added on top. Initially as part of this PR the support
to assign a name to the said service is added which results in DNS
queries to the service name to return all the IPs of the backing
endpoints so that DNS RR behavior on the service name can be achieved.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-05-05 16:47:05 -07:00
Jana Radhakrishnan
89e72d8888 Remove kvstore deps from datastore package
Currently datastore has dependencies on various kv backends.
This is undesirable if datastore had to be used as a backend
agnostic store management package with it's cache layer. This
PR aims to achieve that.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 15:36:44 -07:00
Madhu Venugopal
c92b196d2e Reload config should initialize only the appropriate datastore
With the current implementation, a config relaod event causes all the
datastores to reinitialize and that impacts objects with Persist=false
such as none and host network.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-03-25 01:10:03 -07:00
Alessandro Boch
c92a4e9fd6 Avoid network/endpoint count inconsistences
- ... on ungraceful shutdown during network create
- Allow forceful deletion of network
- On network delete, first mark the network for deletion
- On controller creation, first forcely remove any network
  that is marked for deletion.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-15 09:09:13 -07:00
Santhosh Manohar
f845a45b4f Merge pull request #908 from aboch/dds
Allow pass global datastore config after boot
2016-02-17 15:19:39 -08:00
Alessandro Boch
209cb0b476 Allow to pass global datastore config
- After boot via ReloadConfiguration() method

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-02-17 13:13:58 -08:00
Madhu Venugopal
799369da81 getNetworksFromStore should not fail on inconsistent network state
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-02-11 03:54:12 -08:00
Madhu Venugopal
101e63f593 getNetworksFromStore should return all valid networks
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-02-09 17:12:29 -08:00
Alexander Morozov
74cf622463 Fix some races in getNetworkFromStore
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-01-29 11:06:33 -08:00
Madhu Venugopal
315004b575 Cache scope in network object
Its safe to cache the scope value in network object and can be reused
for cleanup operations. The current implementation assume the presence
of driver during cleanup operation. Since a remote driver may not be
present, we should not fail such cleanup operations. Hence make use of
the scope variable from network object.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-18 17:54:29 -08:00
Alexander Morozov
3569adad28 Fix race in setting ctrlr for network
Race is with network.getController() method.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-01-08 13:32:36 -08:00
Alexander Morozov
7fa78a97c4 Remove redundant assignment to ep.network
Race detector was angry about that assignment

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-11-12 10:38:41 -08:00
Santhosh Manohar
84b1ef9bd5 Fix an issue in overlay network peer EP list maintenance
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-10-24 07:10:03 -07:00
Santhosh Manohar
3da8471681 Handling container rename in libnetwork
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-10-23 05:31:53 -07:00
Jana Radhakrishnan
e5b34e1435 Cleanup service db for the network
Cleanup the service db for the network when the last
container on the network leaves on the host. This is
because we stop watching the network after the last
container leaves and so if we keep the service db
around it might be kept uptodate with containers
joining and leaving in other hosts. The service
db will populated properly when a container joins
this network at a later point in time.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-24 17:41:58 -07:00
Jana Radhakrishnan
c3c4825f80 Purge remote endpoints from watch if it is local
A local endpoint is known to the watch database only
during Join. But the same endpoint can be known to the
watch database as remote endpoint well before the Join
because a CreateEndpoint updates the endpoint to the store.
So on Join when you come to know that this is indeed a
local endpoint remove it from remote endpoint list and add it
to local endpoint list.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-21 21:20:12 -07:00
Madhu Venugopal
07bb3dcdba Dont fail the Get functions if there is an error in one of the stores
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-20 16:57:12 -07:00
Jana Radhakrishnan
33d336ac72 Cleanup dangling local endpoints
When we bootup cleanup all dangling local
endpoints since they are not needed anymore.
The only reason it can happen is when the process
went down ungracefully after an endpoint is
created but before join is successfull.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-19 14:44:27 -07:00
Jana Radhakrishnan
ab8dfb54fe Separate endpoint count data from network object
Currently endpoint count is maintained as part of
network object and the endpoint count gets updated
frequently while the rest of network is quite stable.
Because of the frequent updates to endpoint count the
network object is getting marshalled and unmarshalled
ferquently. This is causing a lot of churn and transient
memory usage. Fix this by creating a deparate object of
endpoint count so that only that gets updated.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-11 23:17:06 -07:00
Jana Radhakrishnan
dbbc561c18 Network ep count increment/decrement needs retry
Today we try to increment/decrement endpoint count
only once even if it is a key modified error. In case
of key modified error we should retry it to allow it to
succeed.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-09 19:37:25 -07:00
Jana Radhakrishnan
71e14dd52a Remove always-on watch for networks and endpoints
Always on watching of networks and endpoints can
affect scalability of the cluster beyond a few nodes.
Remove pro active watching and watch only the objects
you are interested in.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-06 14:15:49 -07:00
Alessandro Boch
2aaef377f3 IPAM driver
- Add IPAM cotract and remote IPAM hooks
 - Add ipam registration in controller
 - Have default IPAM follow ipamapi contract

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 16:18:19 -07:00
Jana Radhakrishnan
3023538a56 Merge pull request #556 from mavenugo/bdb-to
libnetwork to make use of boltdb ConnectionTimeout to avoid deadlock
2015-09-22 19:20:04 -07:00
Madhu Venugopal
27397dcbdf libnetwork to make use of boltdb ConnectionTimeout to avoid deadlock
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-22 13:23:23 -07:00
Madhu Venugopal
725280d03f Providing KVObject option to skip persisting object in kvstore
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-22 08:35:38 -07:00