Commit graph

265 commits

Author SHA1 Message Date
Krasi Georgiev
421c089e98 ingress sandbox hosts and resolve.conf files location didn't respect the custom daemon root directory
Signed-off-by: Krasi Georgiev <krasi@vip-consult.solutions>
2017-04-11 00:51:54 +03:00
Alessandro Boch
18098ab1c8 Add AgentStopWait method
- to signal when the networking cluster agent is stopped

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-04-05 11:13:56 -07:00
Alessandro Boch
b04b258243 Do not clear ingress network in libnetwork
- Now that docker has the code to release the ingress
  network, have docker do the release on cluster leave
  and on graceful daemon shutdown.
  This is a cleaner approach in line with the cleanup
  triggered by who created the resource and will avoid
  races on ingress network removal as revealed by the
  docker tests.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-03-31 14:00:56 -07:00
Alessandro Boch
54d6daf95e Expose ingress network option
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-03-08 17:03:04 -08:00
Santhosh Manohar
8288090b19 Merge pull request #1658 from aboch/iptlck
Serialize non-atomic jump rule programming in bridge
2017-02-22 11:04:37 -08:00
Alessandro Boch
138c4b2a77 Serialize non-atomic jump rule programming in bridge
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-02-22 08:35:26 -08:00
Santhosh Manohar
9e630d61d5 Merge pull request #1631 from mavenugo/nstrict
Reverting the strict network name check
2017-02-01 22:31:20 -08:00
Madhu Venugopal
8e2ca0471c Revert "validate network and endpoint name more strictly"
This reverts commit 761722395d.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-02-01 18:18:17 -08:00
Madhu Venugopal
bb560a1f44 Generating node discovery events to the drivers from networkdb
With the introduction of networkdb, the node discovery events were not
sent to the drivers. This commit generates the node discovery events and
sents it to the drivers interested in it.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-02-01 17:54:51 -08:00
Santhosh Manohar
6ea22f2f50 carry docker/docker #29564
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2017-01-10 13:17:15 -08:00
Alessandro Boch
6dc6fb703b Merge pull request #1595 from sanimej/host
Add support in embedded DNS server for host loopback resolver
2017-01-05 12:18:48 -08:00
allencloud
bc85efdb4f fix nits in comments
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-12-28 18:49:18 +08:00
Santhosh Manohar
bf832ec2a7 Add embedded DNS server support for host loopback resolver
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-12-22 14:34:13 -08:00
Madhu Venugopal
1b28c5e01d 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
Madhu Venugopal
721518279a Handling the new experimental daemon flag
related to https://github.com/docker/docker/issues/29368

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-12-13 13:57:17 -08:00
Madhu Venugopal
224a73d60b Merge pull request #1576 from daehyeok/misspell
Fixed misspelling
2016-12-02 16:02:23 -08:00
Alessandro Boch
fac86cf69a Add missing locks in agent and service code
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-29 13:58:06 -08:00
Daehyeok Mun
f89d6b0073 Fixed misspelling
Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2016-11-28 11:46:52 -07: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
allencloud
99f84ff5a7 update reapNode interval
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-11-08 15:28:42 +08:00
Madhu Venugopal
d1b012d97a Windows overlay driver support
1. Base work was done by msabansal and nwoodmsft
   from : https://github.com/msabansal/docker/tree/overlay
2. reorganized under drivers/windows/overlay and rebased to
   libnetwork master
3. Porting overlay common fixes to windows driver
    * 46f525c
    * ba8714e
    * 6368406
4. Windows Service Discovery changes for swarm-mode
5. renaming default windows ipam drivers as "windows"

Signed-off-by: Madhu Venugopal <madhu@docker.com>
Signed-off-by: msabansal <sabansal@microsoft.com>
Signed-off-by: nwoodmsft <Nicholas.Wood@microsoft.com>
2016-11-03 16:50:04 -07:00
Jana Radhakrishnan
f32c9768a8 Merge pull request #1510 from allencloud/validate-network-and-endpoint-name-strictly
validate network and endpoint name more strictly
2016-11-02 09:57:50 -07:00
Madhu Venugopal
1a8fe1208a Merge pull request #1511 from anusha-ragunathan/fix-drvLoad
Update loadDriver to use pluginv2.
2016-10-24 10:43:55 -07:00
allencloud
761722395d validate network and endpoint name more strictly
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-10-18 11:01:18 +08:00
Anusha Ragunathan
3504ed88d9 Update loadDriver to use pluginv2.
NetworkDrivers were still using v1 to Get plugins. Fix that.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-10-17 15:18:43 -07:00
Akihiro Suda
8e37c3160a add Created to NetworkInfo
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-10-14 05:27:44 +00:00
Santhosh Manohar
3696adb39e Merge pull request #1495 from LK4D4/fix_sb_race
fix race in serializing sandbox to string
2016-10-13 13:16:59 -07:00
Alexander Morozov
7a51c79979 fix race in serializing sandbox to string
Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
2016-10-10 09:41:43 -07:00
Alessandro Boch
eb02cb999b Merge pull request #1500 from anusha-ragunathan/update_path
Update plugingetter import path.
2016-10-07 13:25:42 -07:00
Anusha Ragunathan
5c77ba43e2 Update plugingetter import path.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-10-07 12:00:57 -07:00
Madhu Venugopal
b48e25b44f Add support for NetworkAllocate and NetworkFree in remote driver
Also added an API to return list of builtin network drivers

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-10-05 18:20:02 -07:00
Alessandro Boch
ded6e1934a Clear ingress resources on graceful shutdown
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-09-29 15:01:44 -07:00
Anusha Ragunathan
003e04775b Make libnetwork understand pluginv2.
As part of daemon init, network and ipam drivers are passed a
pluginstore object that implements the plugin/getter interface. Use this
interface methods in libnetwork to interact with network plugins. This
interface provides the new and improved pluginv2 functionality and falls
back to pluginv1 (legacy) if necessary.

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-09-27 15:29:10 -07:00
Madhu Venugopal
9fae5d1779 Merge pull request #1412 from msabansal/dnsv2
DNS support for Windows
2016-09-20 17:35:26 -07:00
msabansal
7f43fd30f3 DNS support
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-09-20 13:02:02 -07:00
Jana Radhakrishnan
f34bd07737 Merge pull request #1449 from sanimej/ingress
Name the ingress sandbox explicitly
2016-09-20 11:39:57 -07:00
Santhosh Manohar
e31db5d6af Name the ingress sandbox explicitly
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-09-15 15:22:57 -07:00
Alessandro Boch
989d9b2cc4 Check if IPv6 is enabled before restoring the network pools
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-09-15 11:21:33 -07:00
Jana Radhakrishnan
ff59f1baab Serialize dynamic network creation
When dynamic networks are created and there is a race in creation of the
same network from two different tasks then one of them will fail while
the other will succeed. For service tasks this is not a big problem
because they will be rescheduled again. But for attachment tasks this
can be a problem since they won't get recreated and making the whole
connection fail. Fixed it by serializing network creation for the
network with the same id and trying to see if the id is present after
coming out of wait.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-09-12 15:24:38 -07:00
Alessandro Boch
2a1ea8a642 Merge pull request #1398 from sanimej/access
Allow reachability across services on the same host
2016-08-30 23:06:12 +02:00
Santhosh Manohar
416a730dad Allow reachability across services on different networks in the same host
This also allows pubslied services to be accessible from containers on bridge
networks on the host

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-08-29 22:25:21 -07:00
Jana Radhakrishnan
9041996509 Nil check ingressSandbox before deleting
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-25 22:41:59 -07:00
Jana Radhakrishnan
b29ba21551 Avoid double close of agentInitDone
Avoid by reinitializing the channel immediately after closing the
channel within a lock. Also change the wait code to cache the channel in
stack be retrieving it from controller and wait on the stack copy of the
channel.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-24 14:00:36 -07:00
Jana Radhakrishnan
4f55b50f93 Cleanup service bindings when leaving cluster
When leaving the entire gossip cluster or when leaving a network
specific gossip cluster, we may not have had a chance to cleanup service
bindings by way of gossip updates due to premature closure of gossip
channel. Make sure to cleanup all service bindings since we are not
participating in the cluster any more.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-19 18:11:15 -07:00
Santhosh Manohar
6e965c03ad Reset the encryption keys on swarm leave
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-08-16 17:37:33 -07:00
Jana Radhakrishnan
4b80c3411d Cleanup ingress network and sandbox on leave
When a node leaves the swarm cluster, we should cleanup the ingress
network and sandbox. This makes sure that when the next time the node
joins the swarm it will be able to update the cluster with the right
information.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-17 13:48:51 -07:00
Santhosh Manohar
ab02b015ef Remove unused key handling functions
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-08-05 04:46:01 -07:00
allencloud
d69747e19e fix typo in comments and log
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-07-30 02:21:10 +08:00
Madhu Venugopal
d6fefd1ad8 Merge pull request #1346 from aboch/lk
Lock in isAgent() and inMaster()
2016-07-22 17:50:39 -07:00
Alessandro Boch
3c36b06cb3 Lock in isAgent() and inMaster()
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-07-22 14:21:28 -07:00
Alessandro Boch
47c071b654 Save the controller config on config reload
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-07-21 12:09:07 -07:00
Madhu Venugopal
68e53443c9 Merge pull request #1323 from aboch/sbr
Return proper error types on sandbox creation
2016-07-12 21:33:30 -07:00
Alessandro Boch
2e88dfa406 Return proper error types on sandbox creation
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-07-12 21:02:10 -07:00
Alessandro Boch
d0192db0cd On agent init, re-join on existing cluster networks
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-07-12 17:35:32 -07:00
Madhu Venugopal
576267bfb9 Moving IPAM initalization out of drvRegistry into libnetwork core
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-07-05 16:42:34 -07:00
Jana Radhakrishnan
bc89397105 Index service on both id and portconfigs
While trying to update loadbalancer state index the service both on id
and portconfig. From libnetwork point of view a service is not just
defined by its id but also the ports it exposes. When a service updates
its port its id remains the same but its portconfigs change which should
be treated as a new service in libnetwork in order to ensure proper
cleanup of old LB state and creation of new LB state.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-27 15:37:22 -07:00
Santhosh Manohar
8ded762a0b Update key handling logic to process keyring with 3 keys
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-06-11 04:50:25 -07:00
Jana Radhakrishnan
d5ce149555 Do not add loadbalancer to unpopulated sandboxes
When adding a loadbalancer to a sandbox, the sandbox may have a valid
namespace but it might not have populated all the dependent network
resources yet. In that case do not populate that endpoint's loadbalancer
into that sandbox yet. The loadbalancer will be populated into the
sandbox when it is done populating all the dependent network resources.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-15 19:58:33 -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
ae90761a21 Reserve addresses of existing local endpoints
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-13 23:48:00 -07:00
Lei Jitang
055c5dd496 Add network restore to support docker live restore container
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-06-13 23:48:00 -07:00
Jana Radhakrishnan
a70909792a Reserve IPAM pools before resource cleanup
If the IPAM pools are not reserved before resource cleanup happens then
the resource release will not happen correctly.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-11 19:19:16 -07:00
Madhu Venugopal
0e284be943 Handle the case of reseting the Cluster Provider for leave cases
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-06-10 08:46:22 -07:00
Jana Radhakrishnan
cd1362e370 Revert "Handle the case of reseting the Cluster Provider for leave caes" 2016-06-09 20:18:49 -07:00
Madhu Venugopal
74fdcb1f4b Handle the case of reseting the Cluster Provider for leave caes
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-06-09 16:51:44 -07:00
Jana Radhakrishnan
26ae9499f0 Set controller ingress state only if ingress
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-07 19:51:44 -07:00
Santhosh Manohar
c4d5bbad7a Use controller methods for handling the encyrption keys from agent
instead of the Provider interface methods.

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-06-05 00:47:30 -07:00
Jana Radhakrishnan
409431edd3 Merge pull request #1217 from sanimej/cpsec
Add support for encrypting gossip traffic
2016-06-06 15:56:37 -07:00
Jana Radhakrishnan
3eff69860d Reset agentInitDone channel when leaving a cluster
When leaving a cluster the agentInitDone should be re-initialized so tha
when a new cluster is initialized this is usable.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-06 11:35:35 -07:00
Jana Radhakrishnan
a63fca344f Add agent initialization wait method in controller
Agent initialization wait method is added to make sure callers for
controller methods which depend on agent initialization to be complete
can wait on it.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-05 19:37:13 -07:00
Jana Radhakrishnan
f98cfa5597 Fix a missing unlock on ingress sandbox failure
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-05 18:59:35 -07:00
Madhu Venugopal
9054ac2b48 Provide a way for libnetwork to make use of Agent mode functionalities
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-06-05 18:41:21 -07:00
Madhu Venugopal
79c0292f53 Merge pull request #1208 from mrjana/lb
Add ingress load balancer
2016-06-05 09:33:14 -07:00
Jana Radhakrishnan
0f89c9b7bc Add ingress load balancer
Ingress load balancer is achieved via a service sandbox which acts as
the proxy to translate incoming node port requests and mapping that to a
service entry. Once the right service is identified, the same internal
loadbalancer implementation is used to load balance to the right backend
instance.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-04 20:38:32 -07:00
Santhosh Manohar
b2b87577d4 Add support for encrypting gossip traffic
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-06-04 03:55:14 -07:00
Madhu Venugopal
1242f27cb5 Merge pull request #1130 from aboch/noips
Avoid persisting ipam data if it can be reconstructed
2016-06-03 19:08:02 -07:00
allencloud
de588f950d fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-05-30 18:20:52 +08:00
Alessandro Boch
651f6ea0fa Avoid persisting ipam data if it can be reconstructed
- Also restore older behavior where overlap check is not run
  when preferred pool is specified. Got broken by recent changes

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-12 10:27:10 -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
0580043718 Add libnetwork agent mode support
libnetwork agent mode is a mode where libnetwork can act as a local
agent for network and discovery plumbing alone while the state
management is done elsewhere. This completes the support for making
libnetwork and its associated drivers to be completely independent of a
k/v store(if needed) and work purely based on the state information
passed along by some some external controller or manager. This does not
mean that libnetwork support for decentralized state management via a
k/v store is removed.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-05-02 18:19:32 -07:00
Jana Radhakrishnan
6fb69f0816 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
Jana Radhakrishnan
7d7b9f2405 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
f539be8a63 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
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
Stefan Weil
13451d9a07 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
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
Alessandro Boch
247e8034b8 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
Madhu Venugopal
a7c52918fd Force delete sandbox during sandboxCleanup
Stale sandbox and endpoints are cleaned up during controller init.
Since we reuse the exact same code-path, for sandbox and endpoint
delete, they try to load the plugin and it causes daemon startup
timeouts since the external plugin containers cant be loaded at that
time. Since the cleanup is actually performed for the libnetwork core
states, we can force delete sandbox and endpoint even if the driver is
not loaded.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-17 14:47:49 -08:00
Madhu Venugopal
ec622bf158 Forced endpoint delete
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-01-12 18:50:28 +00:00
Santhosh Manohar
cf7ed0a717 Embedded DNS server
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-01-07 00:25:26 -08:00
Alessandro Boch
29299b73df 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
Alessandro Boch
dc4285b9a4 Adjust ipam errors
- Remove from contract predefined errors which are no longer
  valid (ex. ErrInvalidIpamService, ErrInvalidIpamConfigService)

- Do not use network driver error for ipam load failure in controller.go

- Bitseq to expose two well-known errors (no more bit available, bit is already set)

- Default ipam to report proper well-known error on RequestAddress()
  based on bitseq returned error

- Default ipam errors to comply with types error interface

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-02 13:38:04 -08:00
Zhang Wei
229e735837 Clean unused variables and fix typo
- Clean some unused variables
- format code.
- fix minor typo

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2015-11-06 11:38:33 +08:00
Jana Radhakrishnan
670302e66b Fix stale sandbox from store problem
At times, when checkpointed sandbox from store cannot be
cleaned up properly we still retain the sandbox in both
the store and in memory. But this sandbox store may not
contain important configuration information from docker.
So when docker requests a new sandbox, instead of using
it as is, reconcile the sandbox state from store with the
the configuration information provided by docker. To do this
mark the sandbox from store as stub and never reveal it to
external searches. When docker requests a new sandbox, update
the stub sandbox and clear the stub flag.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-11-02 00:38:33 -08:00
Jana Radhakrishnan
967917c8b4 Fix race in os sandbox sharing
There is a race in os sandbox sharing code where two containers which
are sharing the os sandbox try to recreate the os sandbox again which
might result in destroying the os sandbox and recreating it. Since the
os sandbox sharing is happening only for default sandbox, refactored the
code to create os sandbox only once inside a `sync.Once` api so that it
happens exactly once and gets reused by other containers. Also disabled
deleting this os sandbox.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-11-01 08:15:32 -08:00
Jana Radhakrishnan
6c23d4073f Fix race in host sandbox creation
Since we share the host sandbox with many containers we
need to serialize creation of the sandbox. Otherwise
container starts may see the namespace path in inconsistent
state.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-30 16:08:33 -07:00
Jana Radhakrishnan
bd77346032 Merge pull request #712 from sanimej/bfix
Handling container rename in libnetwork
2015-10-26 16:12:37 -07:00
Madhu Venugopal
5a0dbbd986 log an error if advertise is configured with a non-local ip-address
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-26 12:21:06 -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
Madhu Venugopal
5ef8d0f038 Add watch retrigger when store restarts
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-21 21:45:52 -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
Alessandro Boch
e0f1ac4b2e 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
Madhu Venugopal
e8370e78d0 Changed Labels to DriverOpts
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-14 16:38:46 -07:00
Madhu Venugopal
3365af97c2 Initializing generic to emtpy map
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-13 10:37:53 -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
Madhu Venugopal
831e3401f3 Merge pull request #606 from mrjana/model
Cleanup dangling sandboxes on boot up
2015-10-08 01:03:32 -07:00
Jana Radhakrishnan
e41b4765bd Cleanup dangling sandboxes on boot up
Currently when docker exits ungracefully it may leave
dangling sandboxes which may hold onto precious network
resources. Added checkpoint state for sandboxes which
on boot up will be used to clean up the sandboxes and
network resources.

On bootup the remaining dangling state in the checkpoint
are read and cleaned up before accepting any new
network allocation requests.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-07 20:08:47 -07:00
Alessandro Boch
b9596c89d6 libnetwork to handle allocation of ipv6
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-07 13:57:28 -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
ddcfab5f81 libnetwork <-> ipam driver interaction
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 16:18:19 -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
Madhu Venugopal
0066225da5 Integration with Docker Discovery
* integrated hostdiscovery package with the new Docker Discovery
* Integrated hostdiscovery package with libnetwork core
* removed libnetwork_discovery tag
* Introduced driver apis for discovery events
* moved overlay driver to make use of the discovery events
* Using Docker Discovery service.
* Changed integration-tests to make use of the new discovery

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-01 12:32:55 -07:00
Madhu Venugopal
a41025e9c0 Fixed a few more issues observed during docker integration
- DisableBridgeCreation is misleading. change it to DefaultBridge
- Dont fail the init if localstore cannot be initialized
- added a convenience function to get endpoint for a container

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-25 09:40:42 -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
08d9578e48 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
Madhu Venugopal
0c089712ec Merge pull request #555 from chenchun/fix_doc
Fix outdated docs and comments
2015-09-22 13:46:27 -07:00
Chun Chen
e82989f845 Fix outdated docs and comments
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-09-22 23:47:44 +08: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
Chun Chen
72567c355b Various refactor and fixes for the previous two commits including:
1. Don't save localscope endpoints to localstore for now.
2. Add common function updateToStore/deleteFromStore to store KVObjects.
3. Merge `getNetworksFromGlobalStore` and `getNetworksFromLocalStore`
4. Add `n.isGlobalScoped` before `n.watchEndpoints` in `addNetwork`
5. Fix integration-tests
6. Fix test failure in drivers/remote/driver_test.go
7. Restore network to store if deleteNework failed
2015-09-22 01:29:51 +08:00
Chun Chen
8babc3d4d3 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
Jana Radhakrishnan
d565a4df48 Push driver config during Init
Currently the driver configuration is pushed through a separate
api. This makes driver configuration possible at any arbitrary
time. This unncessarily complicates the driver implementation.
More importantly the driver does not get access to it's
configuration before it can do the handshake with libnetwork.
This make the internal drivers a little bit different to
external plugins which can get their configuration before the handshake
with libnetwork.

This PR attempts to fix that mismatch between internal drivers and
external plugins.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-09-19 08:43:34 -07:00
Jana Radhakrishnan
cfac9179ba Merge pull request #520 from aboch/vd
Limit valid object names
2015-09-11 11:42:13 -07:00
Madhu Venugopal
84ac14e295 Reexec external key handling
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-11 11:23:40 -07:00
Alessandro Boch
2682309a23 Limit valid object names
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-11 11:02:16 -07:00
Madhu Venugopal
f59502e1bd Support to provide external key to sandbox
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-09 20:26:37 -07:00
Alessandro Boch
b0dd4944f5 Add Refresh() to Sandbox
- Convinience API which detaches the sandbox from
  all endpoints, resets and reapply config options,
  setup discovery files, reattach to the endpoints.
  No change to the osl sandbox in use.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-01 21:48:14 -07:00
Madhu Venugopal
4988fc8e3d Merge pull request #470 from WeiZhang555/master
fix typo
2015-08-30 12:42:14 -07:00
Alessandro Boch
fd43ee1323 Introduce Sandbox entity
- Maps 1 to 1 with container's networking stack
- It holds container's specific nw options which
  before were incorrectly owned by Endpoint.
- Sandbox creation no longer coupled with Endpoint Join,
  sandbox and endpoint have now separate lifecycle.
- LeaveAll naturally replaced by Sandbox.Delete
- some pkg and file renaming in order to have clear
  mapping between structure name and entity ("sandbox")
- Revisited hosts and resolv.conf handling
- Removed from JoinInfo interface capability of setting hosts and resolv.conf paths
- Changed etchosts.Build() to first write the search domains and then the nameservers

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-27 11:19:02 -07:00
Zhang Wei
1f28387d21 fix typo
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
2015-08-26 00:41:32 +08:00
Alex Chan
2e64ce637b Minor spelling fixes in documentation and code comments 2015-06-26 11:02:54 +01:00
Spike Curtis
04bd8f67ad Datastore handles creating objects atomically.
In that commit, AtomicPutCreate takes previous = nil to Atomically create keys
that don't exist.  We need a create operation that is atomic to prevent races
between multiple libnetworks creating the same object.

Previously, we just created new KVs with an index of 0 and wrote them to the
datastore.  Consul accepts this behaviour and interprets index of 0 as
non-existing, but other data backends do no.

 - Add Exists() to the KV interface.  SetIndex() should also modify a KV so
   that it exists.
 - Call SetIndex() from within the GetObject() method on DataStore interface.
   - This ensures objects have the updated values for exists and index.
 - Add SetValue() to the KV interface.  This allows implementers to define
   their own method to marshall and unmarshall (as bitseq and allocator have).
 - Update existing users of the DataStore (endpoint, network, bitseq,
   allocator, ov_network) to new interfaces.
 - Fix UTs.
2015-06-25 10:53:48 -07:00
Jana Radhakrishnan
1ac72c85cb Add LeaveAll support
Currently container can join one endpoint when it is started.
More endpoints can be attached at a later point in time. But
when that happens this attachment should only have meaning
only as long as the container is alive. The attachment should
lose it's meaning when the container goes away. Cuurently there
is no way for the container management code to tell libnetwork
to detach the container from all attached endpoints. This PR
provides an additional API `LeaveAll` which adds this
functionality,

To facilitate this and make the sanbox lifecycle consistent
some slight changes have been made to the behavior of sandbox
management code. The sandbox is no longer destroyed when the
last endpoint is detached from the container. Instead the sandbox
ie kept alive and can only be destroyed with a `LeaveAll` call.
This gives better control of sandbox lifecycle by the container
management code and the sandbox doesn't get destroyed from under
the carpet while the container is still using it.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-19 18:55:26 -07:00
Madhu Venugopal
7084bc27f9 set the kv-provider driver labels only if it is a valid config
without this fix, overlay driver returns an error and that causes the
daemon to quit.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-19 06:30:37 -07:00
Jana Radhakrishnan
271bcd7ba1 Service discovery
Add a minimal service discover support using service names or
service names qualified with network name. This is achieved
by populating the container's /etc/hosts file record with the
appropriate entries

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-19 00:40:37 -07:00
Jana Radhakrishnan
421ef35df2 Support driver labels
Add support for in-tree driver configuration labels
by pushing the labels which has the appropriate
prefix to the corresponding driver.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-18 15:07:20 -07:00
Madhu Venugopal
2677a461de Distributed delete processing
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-17 17:11:20 -07:00
Madhu Venugopal
03504cab65 Few changes to the UI and API implementation
1. replaced --net option for service UI with SERVICE.[NETWORK] format
2. Making using of the default network/driver backend support
3. NetworkName and NetworkType from the UI/API can be empty string
   and it will be replaced with DefaultNetwork and DefaultDriver

As per the design goals, we wanted to keep libnetwork core free of
handling defaults. Rather, the clients (docker & dnet) must handle the
defaultness of these entities.
Also, since there is no API to get these Default values from the
backend, UI will not handle the default values either. Hence, this falls
under the responsibility of the API layer to handle this specific case.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-14 21:57:18 -07:00
Madhu Venugopal
c85a58b6df Return an empty config if nil
Since the Config is a read-only entity, Confg() method returned a value
instead of the pointer. In cases the config is nil, we should return an
empty config.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-13 14:28:56 -07:00
Madhu Venugopal
9f3d1ce3ff 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
9e8974cc64 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
f88824fb8a Reworked endpoint store operation to address a few cases
* Removed network from being marshalled (it is part of the key anyways)
* Reworked the watch function to handle container-id on endpoints
* Included ContainerInfo to be marshalled which needs to be synchronized
* Resolved multiple race issues by introducing data locks

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-10 23:59:29 -07:00
Madhu Venugopal
dca35085f5 datastore support for Endpoint
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-10 21:17:55 -07:00
Madhu Venugopal
0fda541b37 Updating to new Swarm discovery and store APIs
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-10 21:17:55 -07:00
Jana Radhakrishnan
15ddc3717a Add support to trigger immediate garbage collection
Right now the namespace paths are cleaned up every
garbage collection period. But if the daemon is restarted
before all the namespace paths of removed containers are
garbage collected they will remain there forever. The fix
is to provide a GC() api so that garbage collection can be
triggered immediately.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-05 14:15:29 -07:00
Jana Radhakrishnan
a93d08aef5 Add container join priority option to endpoint
When an endpoint is joined by a container it may
optionally pass a priority to resolve resource
conflicts inside the sandbox when more than one
endpoint provides the same kind of resource. If the
the priority is the same for two endpoints with
conflicting resources then the endpoint network names
are used to resolve the conflict.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-06-03 17:48:58 -07:00
Jana Radhakrishnan
800029abb6 Remove container data return value from Join
Now that Endpoint interface has the Info method there is no
need to return container data as a return value in the Join
method. Removed the return value and fixed all the callers.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-05-29 20:11:02 +00:00
Madhu Venugopal
ae8643748d Libnetwork Host Discovery using Swarm Discovery pkg
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-25 16:29:40 -07:00
Madhu Venugopal
481568035f TOML based Configuration support for libnetwork
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-25 16:29:40 -07:00
Madhu Venugopal
594361552e Avoid adding local reserved networks (bridge, none, host) to the datastore
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-05-25 16:29:39 -07:00