Commit graph

100 commits

Author SHA1 Message Date
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