Commit graph

34 commits

Author SHA1 Message Date
Albin Kerouanton
6a2542dacf
libnet: remove Endpoint.anonymous
No more concept of "anonymous endpoints". The equivalent is now an
endpoint with no DNSNames set.

Some of the code removed by this commit was mutating user-supplied
endpoint's Aliases to add container's short ID to that list. In order to
preserve backward compatibility for the ContainerInspect endpoint, this
commit also takes care of adding that short ID (and the container
hostname) to `EndpointSettings.Aliases` before returning the response.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-12-20 19:04:37 +01:00
Sebastiaan van Stijn
cff4f20c44
migrate to github.com/containerd/log v0.1.0
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.

This patch moves our own uses of the package to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 17:52:23 +02:00
Sebastiaan van Stijn
64c6f72988
libnetwork: remove Network interface
There's only one implementation; drop the interface and use the
concrete type instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-22 11:56:41 +02:00
Brian Goff
74da6a6363 Switch all logging to use containerd log pkg
This unifies our logging and allows us to propagate logging and trace
contexts together.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-06-24 00:23:44 +00:00
Cory Snider
c71555f030 libnetwork: return concrete-typed *Endpoint
libnetwork.Endpoint is an interface with a single implementation.

https://github.com/golang/go/wiki/CodeReviewComments#interfaces

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-01-13 14:19:06 -05:00
Cory Snider
0e91d2e0e9 libnetwork: return concrete-typed *Sandbox
Basically every exported method which takes a libnetwork.Sandbox
argument asserts that the value's concrete type is *sandbox. Passing any
other implementation of the interface is a runtime error! This interface
is a footgun, and clearly not necessary. Export and use the concrete
type instead.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-01-13 14:19:06 -05:00
Cory Snider
f96b9bf761 libnetwork: return concrete-typed *Controller
libnetwork.NetworkController is an interface with a single
implementation.

https://github.com/golang/go/wiki/CodeReviewComments#interfaces

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-01-13 14:09:37 -05:00
Sebastiaan van Stijn
cd381aea56
libnetwork: fix empty-lines (revive)
libnetwork/etchosts/etchosts_test.go:167:54: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/osl/route_linux.go:185:74: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/osl/sandbox_linux_test.go:323:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/bitseq/sequence.go:412:48: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/datastore/datastore_test.go:67:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/datastore/mock_store.go:34:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld.go:202:44: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/firewalld_test.go:76:36: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:256:67: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/iptables/iptables.go:303:128: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/networkdb/cluster.go:183:72: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipams/null/null_test.go:44:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/macvlan/macvlan_store.go:45:52: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1058:39: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/port_mapping.go:88:111: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/link.go:26:90: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ipv6_test.go:17:34: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/bridge/setup_ip_tables.go:392:4: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/bridge/bridge.go:804:50: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_serf.go:183:29: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/ov_utils.go:81:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:172:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:209:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:344:89: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/peerdb.go:436:63: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/overlay.go:183:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/drivers/overlay/encryption.go:69:28: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/drivers/overlay/ov_network.go:563:81: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/default_gateway.go:32:43: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:184:64: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/endpoint.go:161:55: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store.go:320:33: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/store_linux_test.go:11:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox.go:571:36: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/service_common.go:317:246: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/endpoint.go:550:17: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/sandbox_dns_unix.go:213:106: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/controller.go:676:85: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/agent.go:876:60: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/resolver.go:324:69: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1153:92: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/network.go:1955:67: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/network.go:2235:9: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/libnetwork_internal_test.go:336:26: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/resolver_test.go:76:35: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:303:38: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/libnetwork_test.go:985:46: empty-lines: extra empty line at the end of a block (revive)
    libnetwork/ipam/allocator_test.go:1263:37: empty-lines: extra empty line at the start of a block (revive)
    libnetwork/errors_test.go:9:40: empty-lines: extra empty line at the end of a block (revive)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 19:21:58 +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
Flavio Crisciani
d418337502 Fix gosimple
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2019-01-03 15:25:37 -08:00
Chris Telfer
1449e88f7a Avoid default gateway collisions
Default gateways truncate the endpoint name to 12 characters.  This can
make network endpoints ambiguous especially for load-balancing sandboxes
for networks with lenghty names (such as with our prefixes).  Address
this by detecting an overflow in the sanbox name length and instead
opting to name the gateway endpoint "gateway_<id>" which should never
collide.

Signed-off-by: Chris Telfer <ctelfer@docker.com>
2018-06-28 12:08:18 -04: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
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
1770ced6c0 Fix bug in needDefaultGW()
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-19 19:23:37 -08:00
msabansal
261fedba8c Default GW support for overlay networks
Signed-off-by: msabansal <sabansal@microsoft.com>
2016-11-08 14:12:29 -08: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
Alessandro Boch
a5aeffcb59 Fix when connecting/disconnecting to/from default gw network
- Restoring original behavior where on disconnect
  from overlay network (only connected network), it also
  disconnects from default gw network.
- On sandbox delete, the leave and delete of each
  endpoint is performed, regardless of whether the endpoint
  is the gw network endpoint. This endpoint is already
  automatically removed in endpoint.sbLeave()
- Also do not let internal network dictate container does
  not need external connectivity. Before this fix, if a container
  was connected to an overlay and an internal network, it may not
  get attached to the default gw network.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-04-06 09:29:41 -07:00
Madhu Venugopal
12f04e292f Revert "Do not leave/delete gw endpoint twice"
This reverts commit c957564753 introduced
via #1064.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-04-05 18:55:16 -07:00
Alessandro Boch
c957564753 Do not leave/delete gw endpoint twice
- On sandbox delete, the leave and delete of each
  endpoint is performed, regardless of whether the endpoint
  is the gw network endpoint. This endpoint is already
  automatically removed in endpoint.sbLeave() by
  sb.clearDefaultGW() when the sandbox is marked for
  deletion.
- Also restoring otiginal behavior where on disconnect
  from overlay network (only connected network), it also
  disconnects from default gw network.
- Also do not let internal network dictate container does
  not need external connectivity. Before this fix, if a container
  was connected to an overlay and an internal network, it may not
  get attached to the default gw network.
- needDefaultGw() takes now into account whether the sandbox
  is marked for deletion

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-04-05 11:32:49 -07:00
Alessandro Boch
1638fbdf27 Move exposed ports from Endpoint to Sandbox
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-03-06 09:31:26 -08:00
Alessandro Boch
7086da757a Handle concurrent creation of default GW network
- Code is not protected against concurrent joins of overlay network

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-25 17:19:58 -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
Chun Chen
186a32acab Add internal network option
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-12-22 09:29:39 +08:00
aboch
405a737a48 Merge pull request #778 from chenchun/disable-default-gateway
Add a network option to disable default gateway
2015-12-03 13:51:43 -08:00
Chun Chen
141c51273f Add DisableGatewayService in JoinInfo to offering drivers the ability to disable default gateway
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-12-03 12:51:28 +08:00
Alessandro Boch
2eadfb8290 Don't connect sbx to default gw nw if default static route is provided
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-02 20:00:27 -08:00
Madhu Venugopal
a687e431c0 Default Gateway endpoints must be annonymous
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-23 16:52:11 -07:00
Madhu Venugopal
71220e2a88 Made use of map[string]string for nw options in default-gateway impl
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-12 15:28:28 -07:00
Jana Radhakrishnan
51699b91aa Merge pull request #560 from mavenugo/adb
Flip the default for the flag AllowNonDefaultBridge in bridge driver
2015-09-24 18:02:12 -07:00
Madhu Venugopal
a42e5f0663 Flip the default for the flag AllowNonDefaultBridge in bridge driver
Replaced it with DisableBridgeCreation and it can be used ONLY in
a special case for docker0 bridge from docker, instead of calling it
from all other case.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-24 02:18:35 -07:00
Santhosh Manohar
1cd9c4dcaa Serialize the endpoint join/leave at the sandbox level
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-09-19 07:31:51 -07:00
Santhosh Manohar
eb54ed5d42 Support for default gateway for containers
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-09-18 05:02:03 -07:00