Commit Graph

43 Commits

Author SHA1 Message Date
Derek McGowan 43f00b74d7 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
Jacob Wen 8c59922031 iptables: jump to DOCKER-USER first
Fixes #1827

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
2017-07-20 16:38:14 +08:00
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 4b3008e95e Fix service logs
- do not error on duplicate service removal
- give some context to service logs,
  this would help debugging related issues

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-02-01 17:32:08 -08:00
Alessandro Boch 522e141ca6 Make virtual service programming more robust
- Do not relay on software flags to decide when to create the
   virtual service. Instead query the kernel for presence.
   So that it cannot happen that a real server creation
   fails because the virtual server is missing.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-02-01 15:54:31 -08:00
Alessandro Boch 07877f913b Gracefully handle redundant ipvs service create failures
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-01-31 16:34:53 -08:00
Alessandro Boch 4289154e13 Fix incorrect error log message
- Failed to _add_ firewall mark... should be _delete_

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-01-23 16:29:03 -08:00
Alessandro Boch 8dcf9960aa Add missing locks in agent and service code
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-29 13:58:06 -08:00
Madhu Venugopal e97818680d Add a ICMP reply rule for service VIP
Ping on VIP has been behaving inconsistently depending on if a task
for a service is local or remote.

With this fix, the ICMP echo-request packets to service VIP are replied
to by the NAT rule to self

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-11-21 08:57:40 -08:00
Madhu Venugopal 097cea5ded Revert "Enable ping for service vip address"
This reverts commit 185fd8d362.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-11-21 03:30:27 -08:00
Madhu Venugopal 0bf056d59f 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
    * 4658085
    * bb736c4
    * f6d8968
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 123a301826 Merge pull request #1501 from sanimej/vip
Enable ping for service vip address
2016-11-02 09:45:14 -07:00
Alessandro Boch 83c9261d1a Block non exposed port traffic on ingress nw interfaces
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-10-27 20:28:08 -07:00
Santhosh Manohar 185fd8d362 Enable ping for service vip address
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-10-27 12:36:41 -07:00
Jana Radhakrishnan b8ef8c2bab Avoid controller/service lock AB/BA situation
Currently there is an instance of controller and service lock being
obtained in different order which causes the AB/BA deadlock. Do not ever
wrap controller lock around service lock.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-10-14 10:17:24 -07:00
Jana Radhakrishnan 6d44146609 Delay port redirect until packet reaches container
With port redirect in the ingress path happening before ipvs in the
ingess sandbox, there is a chance of 5-tuple collision in the ipvs
connection table for two entirely different services have different
PublishedPorts but the same TargetPort. To disambiguate the ipvs
connection table, delay the port redirect from PublishedPort to
TargetPort until after the loadbalancing has happened in ipvs. To be
specific, perform the redirect after the packet enters the real backend
container namespace.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-09-21 16:11:36 -07:00
Jana Radhakrishnan ab555e2bc4 Use complete port configs when plumbing mark rules
Currently, a reference counting scheme is used to reference count all
individual port configs that need to be plumbed in the ingress to make
sure that in situations where a service with the same set of port
configs is getting added or removed doesn't accidentally remove the port
config plumbing if the add/remove notifications come out of order. This
same reference counting scheme is also used for plumbing the port-based
marking rules. But marking rules should not be plumbed based on that
because marks are always different for different instantiations of the
same service. So fixed the code to plumb port-based mark rules based on
the complete set of port configs, while plumbing pure port rules and
proxies based on a filter set of port configs based on the reference
count.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-09-21 09:37:21 -07:00
Alessandro Boch e5daecad8d Merge pull request #1398 from sanimej/access
Allow reachability across services on the same host
2016-08-30 23:06:12 +02:00
Jana Radhakrishnan 18b93cb943 Do not try LB populate on interface-less endpoint
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-30 09:41:16 -07:00
Santhosh Manohar 9dfce0b6e8 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 0bd51967b8 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
Jana Radhakrishnan 52c022a556 Add a narrower SNAT rule for LB egress
The SNAT rules added for LB egress is broader and breaks load balancing
if the service is connected to multiple networks. Make it conditional
based on the subnet to which the network belongs so that the right SNAT
rule gets matched when egressing the corresponding network.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-15 15:38:14 -07:00
Santhosh Manohar 3dabbab24f Merge pull request #1377 from mrjana/bugs
Make service LB work from self
2016-08-05 16:16:53 -07:00
Jana Radhakrishnan 29c8a87757 Make service LB work from self
Make service loadbalancing to work from within one of the containers of
the service. Currently this only works when the loadbalancer selects the
current container. If another container of the same service is chosen,
the connection times out. This fix adds a SNAT rule to change the source
IP to the containers primary IP so that responses can be routed back to
this container.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-04 17:39:38 -07:00
Jana Radhakrishnan 715bf56331 Do not add ingress loadbalancer on service tasks
Ingress loadbalancer is only required to be plumbed in ingress sandboxes
of nodes which are the only mechanism to get traffix outside the cluster
to tasks. Since the tasks are part of ingress network, these
loadbalancers were getting added in all tasks which are exposing ports
which is totally unnecessary resource usage. This PR avoids that.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-04 14:20:54 -07:00
Jana Radhakrishnan c191ea7a14 Make sure to not remove backends on stale notices
Sometimes you may get stale backend removal notices from gossip due to
some lingering state. If a stale backend notice is received and it is
already processed in this node ignore it rather than processing it.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-08-02 14:19:22 -07:00
Jana Radhakrishnan b33b7c68a5 Merge pull request #1205 from allencloud/fix-typos
use grep to find a/an misuse
2016-08-01 09:49:31 -07:00
Jana Radhakrishnan 2895512b8e Do not remove service record while scaling down
While scaling down, currently we are removing the service record even if
the LB entry for the vip is not fully removed. This causes resolution
issues when scaling down. Fixed it by removing the service record only
if the LB for the vip is going away.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-29 11:51:32 -07:00
Jana Radhakrishnan eca7199227 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
Jana Radhakrishnan 97bc97fd02 Match only locally destined requests for ingress
Currently even outgoing connection requests are matched to inject into
DOCKER-INGRESS chain. This is not correct because it disrupts access to
services outside the host on the same service port. Instead inject only
the locally destined packets towards DOCKER-INGRESS chain.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-17 09:57:58 -07:00
Jana Radhakrishnan 3dd4f07cc3 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
Jana Radhakrishnan c53e26dc0f Add service alias support
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-14 16:40:54 -07:00
Jana Radhakrishnan 7b41175653 Change port names in agent proto
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-13 14:11:18 -07:00
Jana Radhakrishnan 08ffeb1cb5 Add support for ingress LB in localhost
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-12 17:28:28 -07:00
Jana Radhakrishnan 178e8abbe5 Add all backend ip into service records if no vip
Right now if no vip is provided only when a new loadbalancer is created
we add the service records of the backend ip. But it should happen all
the time. This is to make DNS RR on service name work.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-09 15:47:09 -07:00
Jana Radhakrishnan c58898536c Fix a lb rule race in loadbalancer
When a goroutine which is adding the service and another which is adding
just a destination interleave the destination which is dependent on the
service may not get added and will result in service working at reduced
scale. The fix is to synchronize this with the service mutex.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-07 17:07:24 -07:00
Jana Radhakrishnan eacc2e26f9 Move ingress port forwarding rules to a chain
- Moved ingress port forwarding rules to its own chain
     - Flushed the chain during init
     - Bound to the swarm ports so no hijacks it.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-07 11:50:17 -07:00
Jana Radhakrishnan 706e5e4f0a Do not attempt LB plumbing until sandbox is ready
Also do not log error messages when adding a destination and it already
exists. This can happen because of duplicate gossip notifications.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-05 13:45:52 -07:00
Jana Radhakrishnan 0c9db265d5 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
allencloud 8acef98c5f use grep to find a/an misuse
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-06-03 16:35:33 +08:00
Jana Radhakrishnan f3ede06779 Add loadbalancer support
This PR adds support for loadbalancing across a group of endpoints that
share the same service configuration as passed in by
`OptionService`. The loadbalancer is implemented using ipvs with just
round robin scheduling supported for now.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-05-26 13:05:58 -07:00