Commit graph

130 commits

Author SHA1 Message Date
Yang Li
b0b5e14b77 test: update tests to use sub-benchmarks
Go 1.7 added the subtest feature which can make table-driven tests much easier to run and debug. Some tests are not using this feature.

Signed-off-by: Yang Li <idealhack@gmail.com>
2018-05-31 11:34:15 +08:00
Euan Harris
ebf0054912 ipam/allocator: Fix typos in error message
Signed-off-by: Euan Harris <euan.harris@docker.com>
2018-05-23 11:03:55 +01:00
Euan Harris
35a81f8173 ipam/allocator_test: Test pool double-release behavior
Releasing a pool which has already been released should fail; this
change increases coverage by a fraction by exercising this path.

Signed-off-by: Euan Harris <euan.harris@docker.com>
2018-05-18 17:32:36 +01:00
Abhinandan Prativadi
2f2811dd14 Adding logs for ipam state
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2018-05-14 15:44:49 -07:00
Abhinandan Prativadi
dfa303e568 fixing test cases
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2018-05-10 14:47:52 -07:00
Abhinandan Prativadi
9fe5cc10b2 Add check for overlapping subnets
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2018-05-10 14:47:07 -07:00
Flavio Crisciani
606e28015a Add test for parallel request pool
Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2018-04-25 16:09:27 -07:00
Sebastiaan van Stijn
a360943a48 Fix golang.org/x/sync canonical import path
The golang.org/x/sync package was vendored using the
github.com/golang/sync URL, but this is not the canonical
URL.

Because of this, vendoring failed in Moby, as it detects
these to be a duplicate import:

    vndr github.com/golang/sync
    2018/03/14 11:54:37 Collecting initial packages
    2018/03/14 11:55:00 Download dependencies
    2018/03/14 11:55:00 Failed to parse config: invalid config format: // FIXME this should be golang.org/x/sync, which is already vendored above

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-03-14 13:11:08 +01:00
Flavio Crisciani
4c8d751400 IPAM tests
Added tests for swarm mode and also some new parallel tests

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2018-03-09 11:07:36 -08:00
Abhinandan Prativadi
a0085a47fd IPAM and Bitseq test cases
This commit contains test cases to verify the changes and to
solidify the library.

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2018-03-09 09:24:10 -08:00
Abhinandan Prativadi
fe629b6eba Fixing concurrent map access
This commit fixes panic due to concurrent map access

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2018-03-08 11:19:45 -08: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
Abhinandan Prativadi
3d44975995 Adding a unit case to verify rollover
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2017-10-03 12:15:34 -07:00
Abhinandan Prativadi
813a24a51c Minor unit test change
Since bit allocation is no longer first available from
the start some verfications are removed/modified to
the change allocation model

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2017-09-29 11:33:26 -07:00
Flavio Crisciani
38382fb29b Merge pull request #1752 from aaronlehmann/sprintfs
all: Avoid trivial uses of Sprintf
2017-08-23 15:49:46 -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
65860255c6 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
Aaron Lehmann
cc0b7e6aad all: Avoid trivial uses of Sprintf
Use the string concatenation operator instead of using Sprintf for
simple string concatenation. This is usually easier to read, and allows
the compiler to detect problems with the type or number of operands,
which would be runtime errors with Sprintf.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-05-09 16:07:09 -07:00
Alessandro Boch
595246bdfb Merge pull request #1568 from likel/refactor
Remove unnecessary string formats
2016-12-29 12:18:06 -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
Ke Li
23ac56fdd0 Remove unnecessary string formats
Signed-off-by: Ke Li <kel@splunk.com>
2016-11-22 09:29:53 +08:00
Alessandro Boch
83dd2c193a Respect auto allocation for --ipv6
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-08 19:05:51 -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
5889b279fb Separate pool parsing from pool auto-allocation
- In default ipam driver. Also improve error message
  in case no good pool is found

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-25 15:02:44 -07:00
Alessandro Boch
a9c9765b33 IPAM allocator to not accept a datastore update if already present
- Restoring the above behavior which got recently broken

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-05-12 16:43:51 -07:00
Alessandro Boch
04f5343139 Make o/p of ipam DumpDatabase() consistent
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-04-15 17:34:48 -07:00
Jana Radhakrishnan
716af1c1ee Need boltdb Register only in tests
Fixing an earlier commit which needlessly registered
boltdb in allocator.go while it is needed only for tests.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 16:34:09 -07:00
Alessandro Boch
216def1e1b Merge pull request #1120 from mrjana/store
Remove kvstore backend deps from datastore package
2016-04-15 15:50:46 -07:00
Jana Radhakrishnan
89e72d8888 Remove kvstore deps from datastore package
Currently datastore has dependencies on various kv backends.
This is undesirable if datastore had to be used as a backend
agnostic store management package with it's cache layer. This
PR aims to achieve that.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 15:36:44 -07:00
Jana Radhakrishnan
4289ea637a Make IPAM work even without a backing store
In general the core IPAM and bitseq implementation has
very little assumptions about the presence of a backing
store. But there are a few places where this assumption exists
and this makes it not useful as a simple in-memory allocator.
This PR removes those false assumptions.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 14:02:30 -07:00
Jana Radhakrishnan
b0d046a1af Remove all netlink/osl deps from ipam/ipamutils
Currently ipam/ipamutils has a bunch of dependencies
in osl and netlink which makes the ipam/ipamutils harder
to use independently with other applications. This PR
modularizes ipam/ipamutils into a standalone package
with no OS level dependencies.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-10 11:05:39 -07:00
Brian Goff
22801e071f Remove pre-defined networks from package init
This moves the initialization of the pre-defined networks to where it's
used instead of in package init.
This reason for this change is having this be populated in `init()`
causes it to always consume cpu, and memory (4.3MB of memory), to
populate even if the package is unused (like for instnace, in a re-exec).

Here is a memory profile of docker/docker just after starting the daemon of the
top 10 largest memory consumers:

Before:
```
      flat  flat%   sum%        cum   cum%
         0     0%     0%    11.89MB 95.96%  runtime.goexit
         0     0%     0%     6.79MB 54.82%  runtime.main
         0     0%     0%     5.79MB 46.74%  main.init
         0     0%     0%     4.79MB 38.67%  github.com/docker/docker/api/server/router/network.init
         0     0%     0%     4.79MB 38.67%  github.com/docker/libnetwork.init
         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipam.init
         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipams/builtin.init
         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.init
         0     0%     0%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.init.1
    4.29MB 34.63% 34.63%     4.29MB 34.63%  github.com/docker/libnetwork/ipamutils.initGranularPredefinedNetworks
```

After:
```
      flat  flat%   sum%        cum   cum%
         0     0%     0%  4439.37kB 89.66%  runtime.goexit
         0     0%     0%  4439.37kB 89.66%  runtime.main
         0     0%     0%  3882.11kB 78.40%  github.com/docker/docker/cli.(*Cli).Run
         0     0%     0%  3882.11kB 78.40%  main.main
 3882.11kB 78.40% 78.40%  3882.11kB 78.40%  reflect.callMethod
         0     0% 78.40%  3882.11kB 78.40%  reflect.methodValueCall
         0     0% 78.40%   557.26kB 11.25%  github.com/docker/docker/api/server.init
  557.26kB 11.25% 89.66%   557.26kB 11.25%  html.init
         0     0% 89.66%   557.26kB 11.25%  html/template.init
         0     0% 89.66%   557.26kB 11.25%  main.init
```

Now, of course the docker daemon will still need to consume this memory, but
at least now re-execs and such won't have to re-init these variables.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-04-04 15:25:29 -04:00
allencloud
67596cc84c Fix some typos.
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-02-29 19:20:50 +08:00
Alessandro Boch
5dc5acfa58 Handle datastore update in Ipam and overlay drivers
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-02-16 13:49:49 -08:00
aboch
d25e25ccb9 Merge pull request #756 from TimWolla/rfc3849
Use documentation IPv6 addresses (RFC 3849) in tests
2016-01-26 11:32:26 -05:00
Bryan Boreham
81c586e0e5 Stop referring to requested IP address as "preferred",
since it is an error if that address is unavailable.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
2016-01-26 15:09:29 +00:00
Alessandro Boch
a509244057 Fix predefined pool reservation
- The pool request code does not behave properly in
  case of concurrent requests when client does not
  specify a preferred pool. It may dispense the same
  predefined pool to different networks.
- The issue is common for local and global
  address spaces

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-22 14:19:41 -08:00
Alessandro Boch
21219731d3 IPAM to run consistency check over its bitmasks
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-14 08:26:14 -08:00
Alessandro Boch
4cb0d27cf9 Improve ipam test coverage
- Test random de-allocation of allocated addresses
  which is closer to real use case
- Test db reconstruction after read from datastore

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-13 02:43:05 -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
David Manouchehri
f24b0aae51 English please. 2015-11-23 20:05:13 +00:00
Tim Düsterhus
7ff429e32d Use documentation IPv6 addresses (RFC 3849) in tests
Signed-off-by: Tim Düsterhus <tim@bastelstu.be>
2015-11-15 18:28:53 +01:00
Alessandro Boch
14b21d5d88 Fix bug in getAddressRange() in default ipam driver
- Callers expect to work with offsets based on master pool

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-11-08 11:30:57 -08:00
Tom Parker
64547e43c0 Minor spelling fix ("likey" => "likely") 2015-10-30 17:18:50 +00:00
Madhu Venugopal
cd971b9db4 Merge pull request #697 from aboch/bq
Do not manipulate bitseq length to reserve broadcast address
2015-10-22 22:27:27 +02:00
Alessandro Boch
115d2ec7d8 Do not manipulate bitseq length to reserve broadcast address
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-22 12:58:45 -07:00
Alessandro Boch
f1b2705d5e Do not refresh the bitmasks on all operations in IPAM
- Currently allocator pulls all the bitmasks from datastore
  before processing each public API. This is not needed as
  the APIs already selectively pull the interested bitmask
  when needed.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-20 18:34:12 -07:00
Jana Radhakrishnan
6d6490b91c Check if address space valid in getStore
Added a check to see if address space is valid in
addrSpaces map before accessing it. Also fixed some
error strings so that it provides better information
to the user.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-12 11:20:29 -07:00
Alessandro Boch
c2064dc18d Reduce logging verbosity in allocator
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-10 05:42:31 -07:00
Alessandro Boch
6026fe772c Remove 2^32 bits restriction on bitsequence
- Allow bitsequence of length 2^64-1
- Updated ID Manager and IPAM

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-10 05:42:26 -07:00
Jana Radhakrishnan
268d41835d Make bridge driver networks persistent
Since libnetwork is going to provide createNetwork
notifications only once when the network is created
bridge network needs to save it's network state in
persistent store so that it becomes available even
after restart.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-08 20:42:45 -07:00
Alessandro Boch
af3eb25d44 Phase-2 bridge driver changes to support IPAM
- Set bridge ipv4 address when bridge is present
- IPv6 changes for bridge
- Convert unit tests to the new model

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-08 16:22:03 -07:00
Alessandro Boch
0cfaa590de Fix in handling aux addresses
- libnetwork should reserve only the auxiliary
  addresses which belong to the container
  addresable pool. And should fail the network
  creation if the aux addr does not belong to
  the master pool.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-07 13:06:41 -07:00
Jana Radhakrishnan
8b1f3432b3 Merge pull request #588 from aboch/d0
ipamutils package
2015-10-06 15:23:06 -07:00
Alessandro Boch
94b6e5e18b Default IPAM to use ipamutils pkg
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-06 15:13:58 -07:00
Madhu Venugopal
f77bdb6589 Merge pull request #594 from mrjana/model
Remove watch on all libnetwork objects
2015-10-06 14:46:48 -07:00
Jana Radhakrishnan
a13f78369f IPAM watch removal and multistore support
Remove the need for watching for IPAM data
structures and add multi store support code and
data reorganization to simplify address space
management.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-06 14:16:06 -07:00
Madhu Venugopal
782d9a4618 ipam must honor preferedIP ahead of random allocation from subPool
Currently the default ipam implementation ignores the prefered ip if the
request is made on an existing sub-pool. The priority should be other
way around.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-10-05 00:40:17 -07:00
Alessandro Boch
b061382c5e Default IPAM to handle local ds
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 22:47:46 -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
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
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
David Calavera
cc02894a50 Move test specific functions to a testutils package.
This way we won't vendor test related functions in docker anymore.
It also moves netns related functions to a new ns package to be able to
call the ns init function in tests. I think this also helps with the
overall package isolation.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-09-07 13:33:28 -04:00
Alessandro Boch
d7803ee53a Fix ip range allocation in ipam
- Current logic about valid addresses is wrong

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch
b2ff78548a Fix preferred ip allocation in ipam
- also provided a new utility to compute the
  host part ip address which is resilient to
  input passed in different representations.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch
5c926bb344 idm and ipam to use bitseq atomic APIs
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch
ee31009744 bitseq to only handle and return unsigned types
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch
467876e723 Control exported types in bitseq
- bitseq users only need to know Handle type

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch
e5842be694 network byte order to bitseq serializer
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07: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
Alessandro Boch
b818ea981d Add datastore to IPAM for configuration
- IPAM to use datastore for the subnets configurations

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 17:17:19 -07:00
Alessandro Boch
e39fc16c55 Rework push reservation w/ datastore
- At Handle creation, first check if an instance of the
  the respective object is already present in the datastore.
- Handle sequence must be saved only if commit
  to datastore is succesfull
- Caller (ipam) needs to manage the retry

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:49:21 -07:00
Alessandro Boch
390a9702d2 Change subnet key schema in ipam
- to addrSpace/subnet/childSubnet

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:49:21 -07:00
Madhu Venugopal
c395cf2eb6 Datastore additions to bitmask management
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-17 16:49:19 -07:00
Alessandro Boch
d1a16bbb84 Add numerical ids manager
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:46:05 -07:00
Alessandro Boch
1f76a79bf7 bitseq to provide handle
- Handle contains sequence and identifier.
  This way datastore integration can be done
  at bitseq level.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00
Alessandro Boch
3ff75bd42d Reorganize libnetwork ipam datastructures
- In order to facilitate usage of datastore
- This makes it slower. Efficiency will be
  revisited later after datastore integration
  is done.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00
Alessandro Boch
a0e0d07250 Add locking to libnetwork ipam
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00
Alessandro Boch
873ea8a224 Add libnetwork ipam implementation
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00
Alessandro Boch
3287a4c830 Add ipam contract
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00