Commit Graph

45 Commits

Author SHA1 Message Date
Flavio Crisciani 6426d1e66f Service discovery race on serviceBindings delete. Bug on IP reuse (#1808)
* Correct SetMatrix documentation

The SetMatrix is a generic data structure, so the description
should not be tight to any specific use

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

* Service Discovery reuse name and serviceBindings deletion

- Added logic to handle name reuse from different services
- Moved the deletion from the serviceBindings map at the end
  of the rmServiceBindings body to avoid race with new services

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

* Avoid race on network cleanup

Use the locker to avoid the race between the network
deletion and new endpoints being created

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

* CleanupServiceBindings to clean the SD records

Allow the cleanupServicebindings to take care of the service discovery
cleanup. Also avoid to trigger the cleanup for each endpoint from an SD
point of view
LB and SD will be separated in the future

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

* Addressed comments

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

* NetworkDB deleteEntry has to happen

If there is an error locally guarantee that the delete entry
on network DB is still honored

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-06-18 05:25:58 -07:00
Flavio Crisciani 4994c597ce
Fixed code issues
Fixed issues highlighted by the new checks

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-06-12 11:31:35 -07:00
Flavio Crisciani d64e71e4f7
Service discovery logic rework
changed the ipMap to SetMatrix to allow transient states
Compacted the addSvc and deleteSvc into a one single method
Updated the datastructure for backends to allow storing all the information needed
to cleanup properly during the cleanupServiceBindings
Removed the enable/disable Service logic that was racing with sbLeave/sbJoin logic
Add some debug logs to track further race conditions

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-06-11 20:49:29 -07:00
Alessandro Boch 16406c8dbd 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
Santhosh Manohar 4693eab00d swarm mode network inspect should provide cluser-wide task details
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2017-03-10 19:12:00 -08:00
Alessandro Boch c4aa329d7b Merge pull request #1586 from sanimej/ptr
Defer PTR queries to external servers based on A/AAAA response
2016-12-21 11:40:08 -08:00
Santhosh Manohar 805efb1843 Defer PTR queries to external servers based on A/AAAA response
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-12-20 14:45:13 -08:00
Madhu Venugopal fb8744be86 Internal interface to differentiate built-in drivers from remote
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-12-19 05:17:42 -08:00
Alessandro Boch 82a12c3af3 Fix bug in link-local unmarshalling
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-21 10:17:38 -08:00
Akihiro Suda e9fe159e20 add Created to NetworkInfo
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-10-14 05:27:44 +00:00
msabansal 52d17c5717 DNS support
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-09-20 13:02:02 -07:00
Santhosh Manohar 321f0bc2a5 Relax SRV name validation and fix external SRV query handling
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-08-14 11:27:07 -07:00
Santhosh Manohar 4b6b13af2c Add support for SRV query in embedded DNS
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-05-19 00:27:59 -07:00
Jana Radhakrishnan ed939ef5c3 Add driver api enhancements for gossip
With the introduction of a driver generic gossip in libnetwork it is not
necessary for drivers to run their own gossip protocol (like what
overlay driver is doing currently) but instead rely on the gossip
instance run centrally in libnetwork. In order to achieve this, certain
enhancements to driver api are needed. This api aims to provide these
enhancements.

The new api provides a way for drivers to register interest on table
names of their choice by returning a list of table names of interest as
a response to CreateNetwork. By doing that they will get notified if a
CRUD operation happened on the tables of their interest, via the newly
added EventNotify call.

Drivers themselves can add entries to any table during a Join call by
invoking AddTableEntry method any number of times during the Join
call. These entries lifetime is the same as the endpoint itself. As soon
as the container leaves the endpoint, those entries added by driver
during that endpoint's Join call will be automatically removed by
libnetwork. This action may trigger notification of such deletion to all
driver instances in the cluster who have registered interest in that
table's notification.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-18 19:55:39 -07:00
Alessandro Boch 64d6c60d42 Merge pull request #1118 from mrjana/api
Add support to accepting arbitrary network ID
2016-04-15 12:52:16 -07:00
Jana Radhakrishnan f76409b411 Add support to accepting arbitrary network ID
Currently the libnetwork function `NewNetwork` does not allow
caller to pass a network ID and it is always generated internally.
This is sufficient for engine use. But it doesn't satisfy the needs
of libnetwork being used as an independent library in programs other
than the engine. This enhancement is one of the many needed to
facilitate a generic libnetwork.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 12:34:21 -07:00
Jana Radhakrishnan 3db103d28d Add overlay manager driver
Because overlay is a builtin driver and global allocation of overlay
resources is probably going to happen in a different node (a single
node) and the actual plumbing of the network is probably going to happen
in all nodes, it makes sense to split the functionality of allocation
into two different packages. The central component(this package) only
implements the NetworkAllocate/Free apis while the distributed
component(the existing overlay driver) implements the rest of the driver
api. This way we can reduce the memory footprint overall.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-14 10:37:42 -07:00
Alessandro Boch b13ac2e1b1 Merge pull request #1103 from mrjana/manager
Add NetworkAllocate/Free to driver api
2016-04-12 15:52:09 -07:00
Jana Radhakrishnan c597100b0f Add NetworkAllocate/Free to driver api
Added NetworkAllocate and NetworkFree apis to the list of
driver apis. The intention of the api is to provide a
centralized way of allocating and freeing network resources
for a network which is cross-host.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-11 16:38:22 -07:00
Jana Radhakrishnan ed06d6c013 Create driver registry package
Currently driver management logic is tightly coupled with
libnetwork package and that makes it very difficult to
modularize it and use it separately. This PR modularizes
the driver management logic by creating a driver registry
package.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-09 09:43:43 -07:00
Alessandro Boch 9e61f05abe Persist ipam driver options
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-04-08 08:18:09 -07:00
Alessandro Boch c0d12322c1 Move exposed ports from Endpoint to Sandbox
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-06 09:31:26 -08:00
Stefan Weil 18a445b35f Fix some typos in comments and strings
All of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-03-01 16:45:14 +01:00
Vincent Demeester 18fbf39c59 Use gofmt with -s instead of goimports
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-02-12 14:07:00 +01:00
Alessandro Boch 94e4e395c5 Introduce discoverapi.Discover interface
- Move DiscoverNew() and DiscoverDelete() methods into the new interface
- Add DatastoreUpdate notification
- Now this interface can be implemented by any drivers, not only network drivers

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-28 12:13:04 -08:00
aboch 014fb9c23d Merge pull request #756 from TimWolla/rfc3849
Use documentation IPv6 addresses (RFC 3849) in tests
2016-01-26 11:32:26 -05:00
Madhu Venugopal ace31dadb5 Forced endpoint delete
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-12 18:50:28 +00:00
Ryan Belgrave 12922fce2e IpamOptions per network not per ipam subnet
Signed-off-by: Ryan Belgrave <rmb1993@gmail.com>
2016-01-07 21:28:54 -05:00
Alessandro Boch 21991ef33a Allow remote IPAM driver to express capability
- So that a DHCP based plugin can express it needs
  the endpoint MAC address when requested for an IP address.
- In such case libnetwork will allocate one if not already
  provided by user

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-17 15:41:47 -08:00
Tim Düsterhus 8da84ff8e2 Use documentation IPv6 addresses (RFC 3849) in tests
Signed-off-by: Tim Düsterhus <tim@bastelstu.be>
2015-11-15 18:28:53 +01:00
Alessandro Boch f2284d468b Allow anonymous endpoint
- Allow to create an endpoint as anonymous.
  An anonymous endpoint does not get added
  to the network service records.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-20 14:05:46 -07:00
Alessandro Boch 4c9fc5a545 Fix ipam state cleanup logic
- Got accidentally broken by another commit

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-15 17:37:22 -07:00
Jana Radhakrishnan cd49ffd80b 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
Alessandro Boch eda95b48f4 Relax restriction on IpamConfig
- Both an empty and nil list of IpamConf object
  will trigger auto-allocation for ipv4.
  Auto-allocation for ipv6 will still be excluded
  in the two cases above.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-09 17:54:28 -07:00
Alessandro Boch 0c2be91253 libnetwork to handle allocation of ipv6
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-07 13:57:28 -07:00
Alessandro Boch e78829b007 Fix in handling aux addresses
- libnetwork should reserve only the auxiliary
  addresses which belong to the container
  addresable pool. And should fail the network
  creation if the aux addr does not belong to
  the master pool.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-07 13:06:41 -07:00
Jana Radhakrishnan 25f496f771 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 6315c9a4b6 libnetwork <-> ipam driver interaction
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 16:18:19 -07:00
Madhu Venugopal 70b6f8e519 Updating tests to use controller.Stop() to cleanup states
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-22 14:07:23 -07:00
Chun Chen b35d1735d4 Add local datastore to persist states of LocalScope network
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-09-21 17:58:51 +08:00
Madhu Venugopal f8eb4da90c Moved the TOML based Configuration to dnet
The configuration format for docker runtime is based on daemon flags and
hence adjusting the libnetwork configuration to accomodate it by moving
the TOML based configuration to the dnet tool.

Also changed the controller configuration via options

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-12 12:46:12 -07:00
Madhu Venugopal 2e40befd82 Replacing isReservedNetwork with Driver capability
Currently store makes use of a static isReservedNetwork check to decide
if a network needs to be stored in the distributed store or not. But it
is better if the check is not static, but be determined based on the
capability of the driver that backs the network.

Hence introducing a new capability mechanism to the driver which it can
express its capability during registration. Making use of first such
capability : Scope. This can be expanded in the future for more such cases.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-10 23:59:38 -07:00
Madhu Venugopal 7bf5bdeb5a TOML based Configuration support for libnetwork
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-25 16:29:40 -07:00
Michael Bridgen c6e78965a9 Make driver packages register themselves via DriverCallback
In the present code, each driver package provides a `New()` method
which constructs a driver of its type, which is then registered with
the controller.

However, this is not suitable for the `drivers/remote` package, since
it does not provide a (singleton) driver, but a mechanism for drivers
to be added dynamically. As a result, the implementation is oddly
dual-purpose, and a spurious `"remote"` driver is added to the
controller's list of available drivers.

Instead, it is better to provide the registration callback to each
package and let it register its own driver or drivers. That way, the
singleton driver packages can construct one and register it, and the
remote package can hook the callback up with whatever the dynamic
driver mechanism turns out to be.

NB there are some method signature changes; in particular to
controller.New, which can return an error if the built-in driver
packages fail to initialise.

Signed-off-by: Michael Bridgen <mikeb@squaremobius.net>
2015-05-11 19:00:06 +01:00
Madhu Venugopal 0011d46ead Remote Driver Registration
This commits brings in a functionality for remote drivers to register
with LibNetwork. The Built-In remote driver is responsible for the
actual "remote" plugin to be made available.

Having such a mechanism makes libnetwork core not dependent on any
external plugin mechanism and also the Libnetwork NB apis are free of
Driver interface.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-06 21:45:30 -07:00