Commit Graph

46 Commits

Author SHA1 Message Date
Derek McGowan 43f00b74d7 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
Abhinandan Prativadi f766f091c8 Adding a unit test to catch offset scenarios
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2017-07-10 11:30:06 -07:00
Abhinandan Prativadi 6ed2ad9a88 Fixing issue with bit allocation byteoffset calculation
The byteoffset calculation was skewed to double include
the offset value calculated. The double calculation
happens if the starting ordinal is part of the head
sequence block. This error in calculation could result
in duplicate but getting allocated eventually propogating
to ipam and vni id allocations

Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
2017-06-09 11:53:28 -07:00
Alessandro Boch 75756e4712 Merge pull request #1568 from likel/refactor
Remove unnecessary string formats
2016-12-29 12:18:06 -08:00
Daehyeok Mun d55c701e0c Fixed misspelling
Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2016-11-28 11:46:52 -07:00
Ke Li a3aa25c794 Remove unnecessary string formats
Signed-off-by: Ke Li <kel@splunk.com>
2016-11-22 09:29:53 +08:00
Daehyeok Mun b735bb2ada 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 291de3dfcf Fix bitseq.SetAnyInRange
- size 1 range is a valid input

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-09-13 11:52:12 -07:00
Alessandro Boch 8b4fb315e5 Merge pull request #1120 from mrjana/store
Remove kvstore backend deps from datastore package
2016-04-15 15:50:46 -07:00
Jana Radhakrishnan b6b3642560 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
Alexander Morozov fe222b2966 bitseq: fix races
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-29 11:56:39 -07:00
Stefan Weil 18a445b35f Fix some typos in comments and strings
All of them were found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-03-01 16:45:14 +01:00
Vincent Demeester 18fbf39c59 Use gofmt with -s instead of goimports
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-02-12 14:07:00 +01:00
Alessandro Boch 15c9f4c634 Allow bitseq caller to run consistency check
Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-01-14 08:25:40 -08:00
Alessandro Boch e88e49248a Increase test coverage in bitsequence
- Cover random allocation/deallocation

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-12-11 16:32:44 -08:00
Alessandro Boch c85356efa5 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
Alexander Morozov 5a748382c1 bitseq: fix race between CopyTo and set
Race detector message:

WARNING: DATA RACE
Write by goroutine 269:
  github.com/docker/libnetwork/bitseq.(*Handle).CopyTo()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/store.go:85 +0x2f6
  github.com/docker/libnetwork/datastore.(*cache).get()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/datastore/cache.go:135 +0x307
  github.com/docker/libnetwork/datastore.(*datastore).GetObject()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/datastore/datastore.go:438 +0x121
  github.com/docker/libnetwork/bitseq.(*Handle).set()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:254 +0x1a5
  github.com/docker/libnetwork/bitseq.(*Handle).Unset()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:227 +0xb0
  github.com/docker/libnetwork/ipam.(*Allocator).ReleaseAddress()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/ipam/allocator.go:446 +0x10bc
  github.com/docker/libnetwork.(*endpoint).releaseAddress()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:830 +0x731
  github.com/docker/libnetwork.(*endpoint).Delete()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:624 +0x8d8
  github.com/docker/libnetwork.(*sandbox).Delete()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:191 +0x1047
  github.com/docker/docker/daemon.(*Daemon).releaseNetwork()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/container_unix.go:1180 +0x676
  github.com/docker/docker/daemon.(*Daemon).Cleanup()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:157 +0x5d
  github.com/docker/docker/daemon.(*containerMonitor).Close()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:111 +0xa4
  github.com/docker/docker/daemon.(*containerMonitor).Start.func1()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:142 +0x14b
  github.com/docker/docker/daemon.(*containerMonitor).Start()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:223 +0x1159
  github.com/docker/docker/daemon.(*containerMonitor).Start-fm()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:147 +0x3b
  github.com/docker/docker/pkg/promise.Go.func1()
      /home/moroz/project/workspace/src/github.com/docker/docker/pkg/promise/promise.go:8 +0x2a

Previous read by goroutine 340:
  github.com/docker/libnetwork/bitseq.(*Handle).set()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:254 +0x133
  github.com/docker/libnetwork/bitseq.(*Handle).Unset()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/bitseq/sequence.go:227 +0xb0
  github.com/docker/libnetwork/ipam.(*Allocator).ReleaseAddress()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/ipam/allocator.go:446 +0x10bc
  github.com/docker/libnetwork.(*endpoint).releaseAddress()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:830 +0x731
  github.com/docker/libnetwork.(*endpoint).Delete()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/endpoint.go:624 +0x8d8
  github.com/docker/libnetwork.(*sandbox).Delete()
      /home/moroz/project/workspace/src/github.com/docker/docker/vendor/src/github.com/docker/libnetwork/sandbox.go:191 +0x1047
  github.com/docker/docker/daemon.(*Daemon).releaseNetwork()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/container_unix.go:1180 +0x676
  github.com/docker/docker/daemon.(*Daemon).Cleanup()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:157 +0x5d
  github.com/docker/docker/daemon.(*containerMonitor).Close()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:111 +0xa4
  github.com/docker/docker/daemon.(*containerMonitor).Start.func1()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:142 +0x14b
  github.com/docker/docker/daemon.(*containerMonitor).Start()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/monitor.go:223 +0x1159
  github.com/docker/docker/daemon.(*containerMonitor).Start-fm()
      /home/moroz/project/workspace/src/github.com/docker/docker/daemon/start.go:147 +0x3b
  github.com/docker/docker/pkg/promise.Go.func1()
      /home/moroz/project/workspace/src/github.com/docker/docker/pkg/promise/promise.go:8 +0x2a

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-11-30 13:18:52 -08:00
Alessandro Boch bafd48ce2f Fix bug in bitsequence.pushReservation
- pushReservation fails to correctly detect when
  the affected block is the last in the current
  sequence. It thinks instead the block is in between
  the sequence. Because of this a couple of issues
  may happen:
   1. The allocation of the last bit causes the creation
      of a phantom sequence (length 0) at the end.
      (This has no side effects).
   2. The allocation of a bit somewhere in the middle of
      the bitmask may lead to a completely incorrect
      sequence pattern.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-11-24 10:23:58 -08:00
Alessandro Boch 094b657ff9 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
Alessandro Boch a49fb6b897 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
Jana Radhakrishnan 925fe1f7fa 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
Alessandro Boch d8565d27b7 Fix in bitseq.NewHandle()
- When creating the handle, write it to store if
  not present. Currently it is written to store
  only on first bit allocation.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 21:33:05 -07:00
Alessandro Boch 6315c9a4b6 libnetwork <-> ipam driver interaction
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-10-03 16:18:19 -07:00
Alessandro Boch ec95763dee 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 2bf6bc8278 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 b35d1735d4 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
Alessandro Boch 037330b881 Allow to set bits in a range in bitseq
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-18 14:42:36 -07:00
David Calavera 3afcd65d6e 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 71f57e33b9 Fix bitsequence set()
- incorrect handling during datastore write

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-09-04 18:15:54 -07:00
Alessandro Boch fa75dc24c4 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 ffd7952f64 bitseq to provide atomic functions
- Also add validation for passed ordinal

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Alessandro Boch 05efb232d0 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 a5fb461351 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 e295febf03 network byte order to bitseq serializer
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-08-16 09:38:17 -07:00
Jana Radhakrishnan 8e69328c3b BitSequence should unmarshal data during get
When bit sequence is trying to get key/value from the
data store it should always unmarshall the json data
before using it, as the data is JSON marshalled before
storing it in the data store.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-07-06 11:25:42 -07:00
Alessandro Boch 4f6d381470 Fix incorrect error handling in bitseq constructor
- We must ignore key not found error when querying
  datastore for initial state.
- Regression introduced by e2a63dff5a

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-07-04 17:35:55 -07:00
Spike Curtis e2a63dff5a 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 0fd6fe8d28 Fix datastore value handling in bitseq
- and do not discard errors

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-18 12:07:04 -07:00
Alessandro Boch 9e9c43e948 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 bca6ec2e64 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
Madhu Venugopal c87a2f4567 Datastore additions to bitmask management
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-06-17 16:49:19 -07:00
Alessandro Boch 62b7668b58 Make bitseq.Handle thread-safe
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:46:08 -07:00
Alessandro Boch b512536cb3 Add numerical ids manager
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:46:05 -07:00
Alessandro Boch eb66d4456e 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 2c26fdf8df Add serialize/deserialize for sequence list
Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00
Alessandro Boch c603907331 Add bitseq package
- Initial version
- It allows handling reservation/release of a finite set
  of resources through large bitmask.
- It represents the bitmask as a list of equal
  consecutive 32 bits long bitmask symbols.
  It basically operates on a run-length encoding
  of the bitmask without encode/decode processing.

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-06-17 16:37:59 -07:00