Skip to content

Commit

Permalink
Vendoring libnetwork
Browse files Browse the repository at this point in the history
Vendoring libnetwork commit: 8fb0a8bc9e3166216ca3da2d0bb15332f6685745
    - Fixes breakage in k/v store handling logic in experimental
    - Adds back all the fixes that went in 1.7.1 to master
    - Change VXLAN port in overlay driver to IANA assigned port

Signed-off-by: Jana Radhakrishnan <[email protected]>
  • Loading branch information
mrjana committed Jul 7, 2015
1 parent 58edd21 commit c6dc6bc
Show file tree
Hide file tree
Showing 32 changed files with 354 additions and 142 deletions.
8 changes: 4 additions & 4 deletions hack/vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ clone git golang.org/x/net 3cffabab72adf04f8e3b01c5baf775361837b5fe https://gith
clone hg code.google.com/p/gosqlite 74691fb6f837

#get libnetwork packages
clone git github.com/docker/libnetwork 4c14cd316f40f16bc1c17e420b18a1902dc575a7
clone git github.com/docker/libnetwork 0517ceae7dea82ded435b99af810efa27b56de73
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4
clone git github.com/hashicorp/serf 7151adcef72687bf95f451a2e0ba15cb19412bf2
clone git github.com/docker/libkv e8cde779d58273d240c1eff065352a6cd67027dd
clone git github.com/vishvananda/netns 5478c060110032f972e86a1f844fdb9a2f008f2c
clone git github.com/vishvananda/netlink 8eb64238879fed52fd51c5b30ad20b928fb4c36c
clone git github.com/docker/libkv 60c7c881345b3c67defc7f93a8297debf041d43c
clone git github.com/vishvananda/netns 493029407eeb434d0c2d44e02ea072ff2488d322
clone git github.com/vishvananda/netlink 20397a138846e4d6590e01783ed023ed7e1c38a6
clone git github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060
clone git github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
clone git github.com/coreos/go-etcd v2.0.0
Expand Down
4 changes: 2 additions & 2 deletions vendor/src/github.com/docker/libkv/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ sudo: false
before_install:
# Symlink below is needed for Travis CI to work correctly on personal forks of libkv
- ln -s $HOME/gopath/src/github.com/${TRAVIS_REPO_SLUG///libkv/} $HOME/gopath/src/github.com/docker
- go get code.google.com/p/go.tools/cmd/vet
- go get code.google.com/p/go.tools/cmd/cover
- go get golang.org/x/tools/cmd/vet
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
- go get github.com/golang/lint/golint
- go get github.com/GeertJohan/fgt
Expand Down
42 changes: 24 additions & 18 deletions vendor/src/github.com/docker/libkv/store/consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,29 @@ func (s *Consul) refreshSession(pair *api.KVPair) error {

if session == "" {
entry := &api.SessionEntry{
Behavior: api.SessionBehaviorDelete,
TTL: s.ephemeralTTL.String(),
Behavior: api.SessionBehaviorDelete, // Delete the key when the session expires
TTL: ((s.ephemeralTTL) / 2).String(), // Consul multiplies the TTL by 2x
LockDelay: 1 * time.Millisecond, // Virtually disable lock delay
}

// Create the key session
session, _, err = s.client.Session().Create(entry, nil)
if err != nil {
return err
}
}

lockOpts := &api.LockOptions{
Key: pair.Key,
Session: session,
}
lockOpts := &api.LockOptions{
Key: pair.Key,
Session: session,
}

// Lock and ignore if lock is held
// It's just a placeholder for the
// ephemeral behavior
lock, _ := s.client.LockOpts(lockOpts)
if lock != nil {
lock.Lock(nil)
// Lock and ignore if lock is held
// It's just a placeholder for the
// ephemeral behavior
lock, _ := s.client.LockOpts(lockOpts)
if lock != nil {
lock.Lock(nil)
}
}

_, _, err = s.client.Session().Renew(session, nil)
Expand Down Expand Up @@ -321,18 +322,18 @@ func (s *Consul) WatchTree(directory string, stopCh <-chan struct{}) (<-chan []*
opts.WaitIndex = meta.LastIndex

// Return children KV pairs to the channel
kv := []*store.KVPair{}
kvpairs := []*store.KVPair{}
for _, pair := range pairs {
if pair.Key == directory {
continue
}
kv = append(kv, &store.KVPair{
kvpairs = append(kvpairs, &store.KVPair{
Key: pair.Key,
Value: pair.Value,
LastIndex: pair.ModifyIndex,
})
}
watchCh <- kv
watchCh <- kvpairs
}
}()

Expand Down Expand Up @@ -374,11 +375,16 @@ func (l *consulLock) Unlock() error {
// AtomicPut put a value at "key" if the key has not been
// modified in the meantime, throws an error if this is the case
func (s *Consul) AtomicPut(key string, value []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, error) {

p := &api.KVPair{Key: s.normalize(key), Value: value}

if previous == nil {
return false, nil, store.ErrPreviousNotSpecified
// Consul interprets ModifyIndex = 0 as new key.
p.ModifyIndex = 0
} else {
p.ModifyIndex = previous.LastIndex
}

p := &api.KVPair{Key: s.normalize(key), Value: value, ModifyIndex: previous.LastIndex}
if work, _, err := s.client.KV().CAS(p, nil); err != nil {
return false, nil, err
} else if !work {
Expand Down
29 changes: 25 additions & 4 deletions vendor/src/github.com/docker/libkv/store/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,32 @@ func (s *Etcd) WatchTree(directory string, stopCh <-chan struct{}) (<-chan []*st
// AtomicPut put a value at "key" if the key has not been
// modified in the meantime, throws an error if this is the case
func (s *Etcd) AtomicPut(key string, value []byte, previous *store.KVPair, options *store.WriteOptions) (bool, *store.KVPair, error) {
if previous == nil {
return false, nil, store.ErrPreviousNotSpecified
}

meta, err := s.client.CompareAndSwap(store.Normalize(key), string(value), 0, "", previous.LastIndex)
var meta *etcd.Response
var err error
if previous != nil {
meta, err = s.client.CompareAndSwap(store.Normalize(key), string(value), 0, "", previous.LastIndex)
} else {
// Interpret previous == nil as Atomic Create
meta, err = s.client.Create(store.Normalize(key), string(value), 0)
if etcdError, ok := err.(*etcd.EtcdError); ok {

// Directory doesn't exist.
if etcdError.ErrorCode == 104 {
// Remove the last element (the actual key)
// and create the full directory path
err = s.createDirectory(store.GetDirectory(key))
if err != nil {
return false, nil, err
}

// Now that the directory is created, create the key
if _, err := s.client.Create(key, string(value), 0); err != nil {
return false, nil, err
}
}
}
}
if err != nil {
if etcdError, ok := err.(*etcd.EtcdError); ok {
// Compare Failed
Expand Down
9 changes: 5 additions & 4 deletions vendor/src/github.com/docker/libkv/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ type Backend string

const (
// CONSUL backend
CONSUL = "consul"
CONSUL Backend = "consul"
// ETCD backend
ETCD = "etcd"
ETCD Backend = "etcd"
// ZK backend
ZK = "zk"
ZK Backend = "zk"
)

var (
Expand Down Expand Up @@ -77,7 +77,8 @@ type Store interface {
// DeleteTree deletes a range of keys under a given directory
DeleteTree(directory string) error

// Atomic operation on a single value
// Atomic CAS operation on a single value.
// Pass previous = nil to create a new key.
AtomicPut(key string, value []byte, previous *KVPair, options *WriteOptions) (bool, *KVPair, error)

// Atomic delete of a single value
Expand Down
44 changes: 34 additions & 10 deletions vendor/src/github.com/docker/libkv/store/zookeeper/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,23 +265,47 @@ func (s *Zookeeper) DeleteTree(directory string) error {
// AtomicPut put a value at "key" if the key has not been
// modified in the meantime, throws an error if this is the case
func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, _ *store.WriteOptions) (bool, *store.KVPair, error) {
if previous == nil {
return false, nil, store.ErrPreviousNotSpecified
}

meta, err := s.client.Set(store.Normalize(key), value, int32(previous.LastIndex))
if err != nil {
// Compare Failed
if err == zk.ErrBadVersion {
return false, nil, store.ErrKeyModified
var lastIndex uint64
if previous != nil {
meta, err := s.client.Set(store.Normalize(key), value, int32(previous.LastIndex))
if err != nil {
// Compare Failed
if err == zk.ErrBadVersion {
return false, nil, store.ErrKeyModified
}
return false, nil, err
}
return false, nil, err
lastIndex = uint64(meta.Version)
} else {
// Interpret previous == nil as create operation.
_, err := s.client.Create(store.Normalize(key), value, 0, zk.WorldACL(zk.PermAll))
if err != nil {
// Zookeeper will complain if the directory doesn't exist.
if err == zk.ErrNoNode {
// Create the directory
parts := store.SplitKey(key)
parts = parts[:len(parts)-1]
if err = s.createFullPath(parts, false); err != nil {
// Failed to create the directory.
return false, nil, err
}
if _, err := s.client.Create(store.Normalize(key), value, 0, zk.WorldACL(zk.PermAll)); err != nil {
return false, nil, err
}

} else {
// Unhandled error
return false, nil, err
}
}
lastIndex = 0 // Newly created nodes have version 0.
}

pair := &store.KVPair{
Key: key,
Value: value,
LastIndex: uint64(meta.Version),
LastIndex: lastIndex,
}

return true, pair, nil
Expand Down
17 changes: 4 additions & 13 deletions vendor/src/github.com/docker/libnetwork/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Roadmap

Libnetwork is a young project and is still being defined.
This document defines the high-level goals of the project and defines the release-relationship to the Docker Platform.

* [Goals](#goals)
* [Project Planning](#project-planning): release-relationship to the Docker Platform.
This document defines the high-level goals of the libnetwork project. See [Project Planning](#project-planning) for information on Releases.

## Long-term Goal

Expand All @@ -18,12 +14,7 @@ libnetwork aims to satisfy that composable need for Networking in Containers.
- Define a flexible model that allows local and remote drivers to provide networking to containers
- Provide a stand-alone tool "dnet" for managing and testing libnetwork

## Project Planning

Libnetwork versions do not map 1:1 with Docker Platform releases.
Milestones and Project Pages are used to define the set of features that are included in each release.
Project Planning
================

| Platform Version | Libnetwork Version | Planning |
|------------------|--------------------|----------|
| Docker 1.7 | [0.3](https://github.com/docker/libnetwork/milestones/0.3) | [Project Page](https://github.com/docker/libnetwork/wiki/Docker-1.7-Project-Page) |
| Docker 1.8 | [1.0](https://github.com/docker/libnetwork/milestones/1.0) | [Project Page](https://github.com/docker/libnetwork/wiki/Docker-1.8-Project-Page) |
[Project Pages](https://github.com/docker/libnetwork/wiki) define the goals for each Milestone and identify the release-relationship to the Docker Platform.
5 changes: 2 additions & 3 deletions vendor/src/github.com/docker/libnetwork/bitseq/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ func NewHandle(app string, ds datastore.DataStore, id string, numElements uint32
h.watchForChanges()

// Get the initial status from the ds if present.
err := h.store.GetObject(datastore.Key(h.Key()...), h)
if err != datastore.ErrKeyNotFound {
if err := h.store.GetObject(datastore.Key(h.Key()...), h); err != nil && err != datastore.ErrKeyNotFound {
return nil, err
}

return h, err
return h, nil
}

// Sequence reresents a recurring sequence of 32 bits long bitmasks
Expand Down
7 changes: 6 additions & 1 deletion vendor/src/github.com/docker/libnetwork/bitseq/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ func (h *Handle) Value() []byte {

// SetValue unmarshals the data from the KV store
func (h *Handle) SetValue(value []byte) error {
return h.FromByteArray(value)
var b []byte
if err := json.Unmarshal(value, &b); err != nil {
return err
}

return h.FromByteArray(b)
}

// Index returns the latest DB Index as seen by this object
Expand Down
Loading

0 comments on commit c6dc6bc

Please sign in to comment.