Commit graph

62 commits

Author SHA1 Message Date
Sebastiaan van Stijn
738b16d873
libnetwork/config: add Config.DriverConfig() and un-export DriverCfg
The driver-configurations are only set when creating a new controller,
using the `config.OptionDriverConfig()` option that can be passed to
`New()`, and used as "read-only" after that.

Taking away any other paths that set these options, the only type used
for per-driver options are a `map[string]interface{}`, so we can change
the type from `map[string]interface{}` to a `map[string]map[string]interface{}`,
(or its "modern" variant: `map[string]map[string]any`), so that it's
no longer needed to cast the type before use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-17 09:57:14 +02:00
Sebastiaan van Stijn
e21ff6c0c9
libnetwork/config: remove IsValidName utility
This utility was not used for "Config", but for Networks and Endpoints.
Having this utility made it look like more than it was, and the related
test was effectively testing stdlib.

Abstracting the validation also was hiding that, while validation does
not allow "empty" names, it happily allows leading/trailing whitespace,
and does not remove that before creating networks or endpoints;

    docker network create "bridge "
    docker network create "bridge  "
    docker network create "bridge   "
    docker network create " bridge  "
    docker network create "  bridge "
    docker network create "   bridge"

    docker network ls --filter driver=bridge
    NETWORK ID     NAME        DRIVER    SCOPE
    d4d53210f185      bridge   bridge    local
    e9afba0d99de     bridge    bridge    local
    69fb7a7ba67c    bridge     bridge    local
    a452bf065403   bridge      bridge    local
    49d96c59061d   bridge      bridge    local
    8eae1c4be12c   bridge      bridge    local
    86dd65b881b9   bridge      bridge    local

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-16 19:42:44 +02:00
Sebastiaan van Stijn
cda187222e
libnetwork/config: remove options that were only used in tests
The OptionLocalKVProvider, OptionLocalKVProviderURL, and OptionLocalKVProviderConfig
options were only used in tests, so un-export them, and move them to the
test-files.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:21 +02:00
Sebastiaan van Stijn
b873d70369
replace libkv with local fork
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 20:51:42 +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
142b522946 libnetwork/config: remove vestiges of global scope
Without (*Controller).ReloadConfiguration, the only way to configure
datastore scopes would be by passing config.Options to libnetwork.New.
The only options defined which relate to datastore scopes are limited to
configuring the local-scope datastore. Furthermore, the default
datastore config only defines configuration for the local-scope
datastore. The local-scope datastore is therefore the only datastore
scope possible in libnetwork. Start removing code which is only
needed to support multiple datastore scopes.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-01-26 17:56:29 -05:00
Sebastiaan van Stijn
267108e113
libnetwork/config: rename ParseConfigOptions() to New()
This function effectively is a constructor, so rename it to better describe
it's functionality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 19:20:55 +02:00
Sebastiaan van Stijn
09cc2f9d0e
libnetwork/config: inline LoadDefaultScopes()
This method was an exported method, but only used as part of ParseConfigOptions,
so inlining it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 17:40:06 +02:00
Sebastiaan van Stijn
528428919e
libnetwork/config: merge DaemonCfg into Config
It was unclear what the distinction was between these configuration
structs, so merging them to simplify.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
46f4a45769
libnetwork/config: remove ParseConfig()
Libnetwork configuration files were only used as part of integration tests using
the dnet utility, which was removed in 7266a956a8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
7d574f5ac6
libnetwork/config: inline ProcessOptions
This method was only used in a single place; inlining it makes it
easier to see what's done.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:37 +02:00
Sebastiaan van Stijn
a8a8bd1e42
libnetwork/config: remove "Experimental" and "Debug" options
These were no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-09-26 12:05:22 +02:00
Albin Kerouanton
414dd017b3
Revert "Added API to set ephemeral port allocator range."
Since commit 2c4a868f64, Docker doesn't
use the value of net.ipv4.ip_local_port_range when choosing an ephemeral
port. This change reverts back to the previous behavior.

Fixes #43054.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2022-06-02 22:56:18 +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
Anca Iordache
00f9b23c3a
libnetwork: remove external DS-based host discovery
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-01-06 18:28:26 +01:00
Eng Zer Jun
c55a4ac779
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated in Go 1.16. This commit
replaces the existing io/ioutil functions with their new definitions in
io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-08-27 14:56:57 +08:00
Sebastiaan van Stijn
427ad30c05
libnetwork: remove unused "testutils" imports
Perhaps the testutils package in the past had an `init()` function to set up
specific things, but it no longer has. so these imports were doing nothing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-18 14:20:37 +02:00
Sebastiaan van Stijn
a7ecbd4b29
libnetwork: replace BurntSushi/toml with pelletier/go-toml
The BurntSushi project is no longer maintained, and the container ecosystem
is moving to use the pelletier/go-toml project instead.

This patch moves libnetwork to use the pelletier/go-toml library, to reduce
our dependency tree and use the same library in all places.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-06-05 00:53:49 +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
Su Wang
2c4a868f64 Added API to set ephemeral port allocator range.
Also reduce the allowed port range as the total number of containers
per host is typically less than 1K.

This change helps in scenarios where there are other services on
the same host that uses ephemeral ports in iptables manipulation.

The workflow requires changes in docker engine (
https://github.com/moby/moby/pull/40055) and this change. It
works as follows:

1. user can now specified to docker engine an option
   --published-port-range="50000-60000" as cmdline argument or
   in daemon.json.
2. docker engine read and pass this info to libnetwork via
   config.go:OptionDynamicPortRange.
3. libnetwork uses this range to allocate dynamic port henceforth.
4. --published-port-range can be set either via SIGHUP or
   restart docker engine
5. if --published-port-range is not set by user, a OS specific
   default range is used for dynamic port allocation.
   Linux: 49153-60999, Windows: 60000-65000
6 if --published-port-range is invalid, that is, the range
  given is outside of allowed default range, no change takes place.
  libnetwork will continue to use old/existing port range for
  dynamic port allocation.

Signed-off-by: Su Wang <su.wang@docker.com>
2019-10-11 18:48:07 +00:00
Akihiro Suda
ce5bc0079b allow propagating custom exec-root (e.g. "/run/docker") to libnetwork-setkey
The docker daemon needs to be modified as follows:

    diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go
    index 00ace320df..ea7daa72df 100644
    --- a/daemon/oci_linux.go
    +++ b/daemon/oci_linux.go
    @@ -809,7 +809,7 @@ func (daemon *Daemon) createSpec(c *container.Container) (retSpec *specs.Spec, e
                        s.Hooks = &specs.Hooks{
                                Prestart: []specs.Hook{{
                                        Path: target,
    -                                   Args: []string{"libnetwork-setkey", c.ID, daemon.netController.ID()},
    +                                   Args: []string{"libnetwork-setkey", c.ID, daemon.netController.ID(), "-exec-root="+daemon.configStore.GetExecRoot()},
                                }},
                        }
                }

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-09-14 14:09:09 +09:00
selansen
4484ea17c3 Allow user to specify default address pools for docker networks
This is new feature that allows  user to specify which subnetwork
 Docker contrainer should choose from when it creates bridge network.

 This libnetwork commit is to address moby PR 36054
Signed-off-by: selansen <elango.siva@docker.com>
2018-02-22 12:14:59 -05:00
Flavio Crisciani
a6073649e9 Add a minimum value for the CP MTU
Avoid negative numbers and also set a lower bondary.
500 will mean 400 bytes minimum payload that will allow
at least a couple of gossip message to fit.
There is not theoretical limit becasue the message is made of
strings so there is still the possibility to have cases where
the 400 bytes are not enough to fit a single message, but
in that case we should start thinking why do I need a node
name that is long as an enciclopedia

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-08-14 09:26:41 -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
ecb3daa49e Fix warn log
format wrong

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-07-28 13:30:53 -07:00
Flavio Crisciani
60b5add4af NetworkDB allow setting PacketSize
- Introduce the possibility to specify the max buffer length
  in network DB. This will allow to use the whole MTU limit of
  the interface

- Add queue stats per network, it can be handy to identify the
  node's throughput per network and identify unbalance between
  nodes that can point to an MTU missconfiguration

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-07-26 13:44:33 -07:00
Flavio Crisciani
34ce7c7e6a Revert "Move Cluster provider back to Moby"
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-05-25 10:47:02 -07:00
Flavio Crisciani
627da8bf04 Moved the cluster provider to Moby
Moved the cluster provider interface definition from
libnetwork to moby

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-05-24 11:28:23 -07:00
Flavio Crisciani
a2bf0b35d6 Fix for swarm/libnetwork init race condition
This change cleans up the SetClusterProvider method.
Swarm calls the SetClusterProvider to pass to libnetwork the pointer
of the provider from which libnetwork can fetch all the information to
initialize the internal agent.

The method can be and is called multiple times passing the same value,
with the previous logic that was erroneusly spawning multiple go routines that
were making possiblea race between an agentInit and an agentClose.

The new logic aims to disallow it by checking for the provider passed and
ensuring that if the provider is already present there is nothing to do because
there is already an active go routine that is ready to process cluster events.
Moreover a patch on moby side takes care of clearing up the Cluster Events
dispacthing using only 1 channel to handle all the events types.
This will also guarantee in order event handling because now all the events are
piped into one single channel.

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2017-05-04 15:35:28 -07: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
4d1334c9ee Revert "Allow spaces in network names"
This reverts commit 85b22fabbe.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-02-01 18:18:11 -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
Alessandro Boch
85b22fabbe Allow spaces in network names
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-17 10:02:16 -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
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
5c77ba43e2 Update plugingetter import path.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-10-07 12:00:57 -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
Tonis Tiigi
d46e5c83dd Remove pkg/tlsconfig dependency
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-09-06 14:10:58 -07:00
Madhu Venugopal
25f0573785 Make osl sandbox basepath configurable via execroot.
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2016-07-18 05:14:39 -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
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
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
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
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
wenchma
0b07ad6202 Fixes some typo errors
Signed-off-by: Wen Cheng Ma <wenchma@cn.ibm.com>
2016-01-13 12:59:24 +08:00
Madhu Venugopal
74376e8676 Moved the default local and global store to new root
This is required in order to provide a clean switchover.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-11 22:57:24 -07:00
Madhu Venugopal
4543607d74 Merge pull request #602 from dhiltgen/tls
Add support for configuring TLS
2015-10-08 15:56:10 -07:00
Daniel Hiltgen
50098e5c7b Add support for configuring TLS
This adds a new options configuration routine that the engine
can call in order to configure TLS for libnetworks KV store.

Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
2015-10-07 17:49:49 -07:00
Madhu Venugopal
e5ee4ada8b Removing the endpoint name restriction
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-07 14:51:40 -07:00