Commit graph

177 commits

Author SHA1 Message Date
Sebastiaan van Stijn
e34ab5200d
fix formatting of "nolint" tags for go1.19
The correct formatting for machine-readable comments is;

    //<some alphanumeric identifier>:<options>[,<option>...][ // comment]

Which basically means:

- MUST NOT have a space before `<identifier>` (e.g. `nolint`)
- Identified MUST be alphanumeric
- MUST be followed by a colon
- MUST be followed by at least one `<option>`
- Optionally additional `<options>` (comma-separated)
- Optionally followed by a comment

Any other format will not be considered a machine-readable comment by `gofmt`,
and thus formatted as a regular comment. Note that this also means that a
`//nolint` (without anything after it) is considered invalid, same for `//#nosec`
(starts with a `#`).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4f08346686)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-07-15 13:45:13 +02:00
Sebastiaan van Stijn
7b692a421b
libnetwork: remove more config bits related to external k/v stores
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:45:45 +01:00
Sebastiaan van Stijn
350e303c7f endpoint: remove redundant doUpdateHostsFile() function
The second (sandbox) argument was unused, and it was only
used in a single location, so we may as well inline the
check.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-09 22:38:34 +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
fanjiyun
a24e5f5fd4 reduce parameters for func JoinOptionPriority
Signed-off-by: fanjiyun <fan.jiyun@zte.com.cn>
2020-05-15 18:29:54 +08:00
Kamil Domański
c4fcd7059c etchosts: additionally include the container's IPv6 address if available
Signed-off-by: Kamil Domański <kamil@domanski.co>
2019-09-04 01:58:00 +02:00
Kamil Domański
226fde5cdd etchosts: allow adding multiple container ips
Signed-off-by: Kamil Domański <kamil@domanski.co>
2019-08-30 23:49:33 +02:00
Chris Telfer
ea2fa20859 Add endpoint load-balancing mode
This is the heart of the scalability change for services in libnetwork.
The present routing mesh adds load-balancing rules for a network to
every container connected to the network.  This newer approach creates a
load-balancing endpoint per network per node.  For every service on a
network, libnetwork assigns the VIP of the service to the endpoint's
interface as an alias.  This endpoint must have a unique IP address in
order to route return traffic to it.  Traffic destined for a service's
VIP arrives at the load-balancing endpoint on the VIP and from there,
Linux load balances it among backend destinations while SNATing said
traffic to the endpoint's unique IP address.

The net result of this scheme is that each node in a swarm need only
have one set of load balancing state per service instead of one per
container on the node.  This scheme is very similar to how services
currently operate on Windows nodes in libnetwork.  It (as with Windows
nodes) costs the use of extra IP addresses in a network (one per node)
and an extra network hop in the stack, although, always in the stack
local to the container.

In order to prevent existing deployments from suddenly failing if they
failed to allocate sufficient address space to include per-node
load-balancing endpoint IP addresses, this patch preserves the existing
functionality and activates the new functionality on a per-network
basis depending on whether the network has a load-balancing endpoint.
Eventually, moby should always set this option when creating new
networks and should only omit it for networks created as part of a swarm
that are not marked to use endpoint load balancing.

This patch also normalizes the code to treat "load" and "balancer"
as two separate words from the perspectives of variable/function naming.
This means that the 'b' in "balancer" must be capitalized.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-06-28 12:08:18 -04:00
Chris Telfer
c4d507b566 Remove non-service cluster info on sbLeave
The system should remove cluster service info including networkDB
entries and DNS entries for container endpoints that are not part of a
service as well as those that are part of a service.  This used to be
the normal sequence of operations but it moved to
sandbox.DisableService() in an effort to more gracefully handle endpoint
removal from a service (which proved insufficient).  Unfortunately
subsequent changes also removed the newly-mandetory call to
sandbox.DisableService() preventing proper cleanup for non-service
container endpoints.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-05-31 14:21:55 -04:00
Chris Telfer
147912afad Merge pull request #2132 from cziebuhr/2093-iface_order2
Improve interface order
2018-05-30 12:26:38 -04:00
Christoph Ziebuhr
40923e7353 Use ordered array instead of heap for sb.endpoints
Signed-off-by: Christoph Ziebuhr <chris@codefrickler.de>
2018-03-21 10:31:56 +01:00
Chris Telfer
7d7412f957 Gracefully remove LB endpoints from services
This patch attempts to allow endpoints to complete servicing connections
while being removed from a service.  The change adds a flag to the
endpoint.deleteServiceInfoFromCluster() method to indicate whether this
removal should fully remove connectivity through the load balancer
to the endpoint or should just disable directing further connections to
the endpoint.  If the flag is 'false', then the load balancer assigns
a weight of 0 to the endpoint but does not remove it as a linux load
balancing destination.  It does remove the endpoint as a docker load
balancing endpoint but tracks it in a special map of "disabled-but-not-
destroyed" load balancing endpoints.  This allows traffic to continue
flowing, at least under Linux.  If the flag is 'true', then the code
removes the endpoint entirely as a load balancing destination.

The sandbox.DisableService() method invokes deleteServiceInfoFromCluster()
with the flag sent to 'false', while the endpoint.sbLeave() method invokes
it with the flag set to 'true' to complete the removal on endpoint
finalization.  Renaming the endpoint invokes deleteServiceInfoFromCluster()
with the flag set to 'true' because renaming attempts to completely
remove and then re-add each endpoint service entry.

The controller.rmServiceBinding() method, which carries out the operation,
similarly gets a new flag for whether to fully remove the endpoint.  If
the flag is false, it does the job of moving the endpoint from the
load balancing set to the 'disabled' set.  It then removes or
de-weights the entry in the OS load balancing table via
network.rmLBBackend().  It removes the service entirely via said method
ONLY IF there are no more live or disabled load balancing endpoints.
Similarly network.addLBBackend() requires slight tweaking to properly
manage the disabled set.

Finally, this change requires propagating the status of disabled
service endpoints via the networkDB.  Accordingly, the patch includes
both code to generate and handle service update messages.  It also
augments the service structure with a ServiceDisabled boolean to convey
whether an endpoint should ultimately be removed or just disabled.
This, naturally, required a rebuild of the protocol buffer code as well.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-03-16 15:19:49 -04:00
abhi
5ab37a55a1 Delete service info from cluster when service is disabled
This PR contains a fix for moby/moby#30321. There was a moby/moby#31142
PR intending to fix the issue by adding a delay between disabling the
service in the cluster and the shutdown of the tasks. However
disabling the service was not deleting the service info in the cluster.
Added a fix to delete service info from cluster and verified using siege
to ensure there is zero downtime on rolling update of a service.

Signed-off-by: abhi <abhi@docker.com>
2018-01-09 13:53:00 -08:00
Pradip Dhara
a3c3a596dd PR feedback
Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2017-09-07 10:36:11 -07:00
Pradip Dhara
43360c627f Enabling ILB/ELB on windows using per-node, per-network LB endpoint.
Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2017-08-29 00:17:42 -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
Flavio Crisciani
39d2204896 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
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
Alessandro Boch
b4e5078bd5 Make sure sbJoin programming rollback happens on each error
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-04-17 10:58:14 -07:00
Alessandro Boch
23b43b1557 Remove gw endpoint on gw nw join failure
- Currently if the join fails, the gw endpoint becomes
  stale and stays connected to the gw network.
- Also fix sbJoin to do the cleanup in case
  setupDefaultGW() fails

Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-04-11 17:48:46 -07:00
Alessandro Boch
ab0ac83e89 Merge pull request #1670 from timchenxiaoyu/endpointtypo
fix endpoint error
2017-04-10 13:52:27 -07:00
Madhu Venugopal
56ae6ff330 Merge pull request #1687 from aboch/rnm
Fix rename for containers on swarm network
2017-03-30 07:32:55 -07:00
Alessandro Boch
ed935930b5 Fix rename for containers on swarm network
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-03-16 14:09:26 -07:00
Alessandro Boch
dce60f5afb Remove enpoint state from cluster on join failure
Signed-off-by: Alessandro Boch <aboch@docker.com>
2017-03-15 16:44:47 -07:00
timchenxiaoyu
c679b071f0 fix endpoint error
Signed-off-by: timchenxiaoyu <837829664@qq.com>
2017-03-02 18:21:08 +08:00
Madhu Venugopal
b6540296b0 Revert "Enable ping for service vip address"
This reverts commit ddc74ffced.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-11-21 03:30:27 -08:00
Santhosh Manohar
27500b1e35 Separate service LB & SD from network plumbing
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-11-17 13:09:14 -08:00
Jana Radhakrishnan
f681e896ae Merge pull request #1531 from daehyeok/logrus_formating
Fix logrus formatting
2016-11-08 13:23:39 -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
Alessandro Boch
0d32a1924e Check subnet overlap when programming of sandbox interface
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-08 11:22:38 -08:00
Alessandro Boch
c5ca82daf4 Merge pull request #1519 from sanimej/newlb
Add sandbox API for task insertion to service LB and service discovery
2016-11-03 13:31:46 -07:00
Jana Radhakrishnan
ea579a4d0e Merge pull request #1477 from allencloud/fix-nits-in-comments
fix nits in comments and log
2016-11-02 09:58:18 -07:00
Jana Radhakrishnan
b1e753137f Merge pull request #1501 from sanimej/vip
Enable ping for service vip address
2016-11-02 09:45:14 -07:00
allencloud
a1ed5b7be2 fix nits in comments and log
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-10-29 19:35:18 +08:00
Santhosh Manohar
ddc74ffced Enable ping for service vip address
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-10-27 12:36:41 -07:00
Jana Radhakrishnan
fd70adfac5 Merge pull request #1494 from aboch/sipt
Do not update hosts file with internal networks endpoint IP
2016-10-26 13:00:22 -07:00
Santhosh Manohar
a7e1718800 Add sandbox API for task insertion to service LB and service discovery
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-10-25 05:41:44 -07:00
Alessandro Boch
b859ce411b Do not update hosts file with internal networks endpoint IP
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-10-20 16:10:01 -07:00
Shayan Pooya
e2008b82e8 Handle containers with different network drivers
There is no guarantees that the ep and extEp are using the same driver.
If they are not using the same drivers, the driver for ep will not know
about the networks of extEp and fails the RevokeExternalConnectivity
call.

Signed-off-by: Shayan Pooya <shayan@liveve.org>
2016-10-06 09:38:31 -07:00
msabansal
7f43fd30f3 DNS support
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-09-20 13:02:02 -07:00
Santhosh Manohar
c9bf3b594e Revert "Add sandbox API for task insertion to service LB and service discovery"
This reverts commit 8298e278be.

Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-09-14 08:44:20 -07:00
Santhosh Manohar
8298e278be Add sandbox API for task insertion to service LB and service discovery
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-09-08 17:39:45 -07:00
Jana Radhakrishnan
56de900a7b Decrement epCnt only after all cleanup
Currently the endpoint count is being decremented before the driver
cleanup and more importantly before releasing the ip address. This is
racy as it creates a time window where we already have decremented the
endpoint count and so the network can be deleted now. But we haven't
released the IP address yet and the pool is already gone. Although there
is no harm done since the pool is already gone. it generates unnecessary
error message about not able to release the address. Also if the driver
cleanup fails we really should not decrement endpoint count.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-09-07 11:33:29 -07:00
Santhosh Manohar
44fabf5343 Remove UDP connection cachig in embedded DNS server
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-07-23 09:05:49 -07:00
Santhosh Manohar
902ead3109 Update service DB on deletion of containers in bridge networks
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2016-07-22 14:51:36 -07:00
Alessandro Boch
64673bce0a Remove locator check on endpoint force removal
- If an endpoint is forcibly removed, it should not
  matter whether the locator info is present. If
  the daemon was started w/o the --cluster-advertise
  option (the option is not mandatory), then the
  locator would be empty for any endpoint.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-06-22 18:34:30 -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
Jana Radhakrishnan
acac7ee812 Add service alias support
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-06-14 16:40:54 -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