From e04a0b2f143812dae9c05ebaa63a651b168b9670 Mon Sep 17 00:00:00 2001 From: Daniel Ferstay Date: Thu, 2 Mar 2017 16:42:04 -0800 Subject: [PATCH] Move to the docker/swarm/1915-4 branch of libkv which addresses issue #1915 Signed-off-by: Daniel Ferstay --- Godeps/Godeps.json | 160 ++++++++++++++++-- vendor/github.com/docker/libkv/.travis.yml | 2 +- vendor/github.com/docker/libkv/MAINTAINERS | 6 - .../docker/libkv/store/zookeeper/zookeeper.go | 58 ++++--- 4 files changed, 190 insertions(+), 36 deletions(-) diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 0f8113c459..b1d5b14f98 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -206,28 +206,28 @@ }, { "ImportPath": "github.com/docker/libkv", - "Comment": "v0.2.1", - "Rev": "aabc039ad04deb721e234f99cd1b4aa28ac71a40" + "Comment": "v0.2.1-6-g553fb2b", + "Rev": "553fb2b4cba50c8f2840671db375f8522b506419" }, { "ImportPath": "github.com/docker/libkv/store", - "Comment": "v0.2.1", - "Rev": "aabc039ad04deb721e234f99cd1b4aa28ac71a40" + "Comment": "v0.2.1-6-g553fb2b", + "Rev": "553fb2b4cba50c8f2840671db375f8522b506419" }, { "ImportPath": "github.com/docker/libkv/store/consul", - "Comment": "v0.2.1", - "Rev": "aabc039ad04deb721e234f99cd1b4aa28ac71a40" + "Comment": "v0.2.1-6-g553fb2b", + "Rev": "553fb2b4cba50c8f2840671db375f8522b506419" }, { "ImportPath": "github.com/docker/libkv/store/etcd", - "Comment": "v0.2.1", - "Rev": "aabc039ad04deb721e234f99cd1b4aa28ac71a40" + "Comment": "v0.2.1-6-g553fb2b", + "Rev": "553fb2b4cba50c8f2840671db375f8522b506419" }, { "ImportPath": "github.com/docker/libkv/store/zookeeper", - "Comment": "v0.2.1", - "Rev": "aabc039ad04deb721e234f99cd1b4aa28ac71a40" + "Comment": "v0.2.1-6-g553fb2b", + "Rev": "553fb2b4cba50c8f2840671db375f8522b506419" }, { "ImportPath": "github.com/gogo/protobuf/proto", @@ -413,6 +413,146 @@ "ImportPath": "github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/difflib", "Comment": "v1.1.3", "Rev": "f390dcf405f7b83c997eac1b06768bb9f44dec18" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/go-connections/nat", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/go-units", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/distribution/reference", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/distribution/digest", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/api/types/volume", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/go-connections/sockets", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/go-connections/tlsconfig", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/pkg/errors", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/golang.org/x/net/context", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/golang.org/x/net/context/ctxhttp", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/Microsoft/go-winio", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/Sirupsen/logrus", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/opencontainers/runc/libcontainer/user", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/golang.org/x/net/proxy", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/golang.org/x/sys/windows", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/golang.org/x/sys/unix", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/libkv", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/libkv/store", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/libkv/store/consul", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/libkv/store/etcd", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/docker/libkv/store/zookeeper", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/hashicorp/consul/api", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/coreos/etcd/client", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/samuel/go-zookeeper/zk", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/coreos/etcd/pkg/pathutil", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/coreos/etcd/pkg/types", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/ugorji/go/codec", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" + }, + { + "ImportPath": "github.com/docker/docker/vendor/github.com/mattn/go-shellwords", + "Comment": "docs-v1.12.0-rc4-2016-07-15-3446-gc8388a5", + "Rev": "c8388a52ec7a328b6aee3c48d31bd7f3e0b14aeb" } ] } diff --git a/vendor/github.com/docker/libkv/.travis.yml b/vendor/github.com/docker/libkv/.travis.yml index 23ef6e054b..a7a3bcffc7 100644 --- a/vendor/github.com/docker/libkv/.travis.yml +++ b/vendor/github.com/docker/libkv/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.5.3 + - 1.7.1 # let us have speedy Docker-based Travis workers sudo: false diff --git a/vendor/github.com/docker/libkv/MAINTAINERS b/vendor/github.com/docker/libkv/MAINTAINERS index 4dd59c7e27..4a8bbc6135 100644 --- a/vendor/github.com/docker/libkv/MAINTAINERS +++ b/vendor/github.com/docker/libkv/MAINTAINERS @@ -11,7 +11,6 @@ [Org] [Org."Core maintainers"] people = [ - "abronan", "aluzzardi", "sanimej", "vieux", @@ -25,11 +24,6 @@ # ADD YOURSELF HERE IN ALPHABETICAL ORDER - [people.abronan] - Name = "Alexandre Beslic" - Email = "abronan@docker.com" - GitHub = "abronan" - [people.aluzzardi] Name = "Andrea Luzzardi" Email = "al@docker.com" diff --git a/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go b/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go index ff8d4ebe0f..ec256aea8c 100644 --- a/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go +++ b/vendor/github.com/docker/libkv/store/zookeeper/zookeeper.go @@ -13,7 +13,9 @@ const ( // SOH control character SOH = "\x01" - defaultTimeout = 10 * time.Second + defaultTimeout = 10 * time.Second + + syncRetryLimit = 5 ) // Zookeeper is the receiver type for @@ -66,19 +68,29 @@ func (s *Zookeeper) setTimeout(time time.Duration) { // Get the value at "key", returns the last modified index // to use in conjunction to Atomic calls func (s *Zookeeper) Get(key string) (pair *store.KVPair, err error) { - resp, meta, err := s.client.Get(s.normalize(key)) - if err != nil { - if err == zk.ErrNoNode { - return nil, store.ErrKeyNotFound + var resp []byte + var meta *zk.Stat + + // To guard against older versions of libkv + // creating and writing to znodes non-atomically, + // We try to resync few times if we read SOH or + // an empty string + for i := 0; i <= syncRetryLimit; i++ { + resp, meta, err = s.client.Get(s.normalize(key)) + + if err != nil { + if err == zk.ErrNoNode { + return nil, store.ErrKeyNotFound + } + return nil, err } - return nil, err - } - // FIXME handle very rare cases where Get returns the - // SOH control character instead of the actual value - if string(resp) == SOH { - return s.Get(store.Normalize(key)) + if (string(resp) == SOH || string(resp) == "") && i < syncRetryLimit { + if _, err = s.client.Sync(s.normalize(key)); err != nil { + return nil, err + } + } } pair = &store.KVPair{ @@ -91,14 +103,21 @@ func (s *Zookeeper) Get(key string) (pair *store.KVPair, err error) { } // createFullPath creates the entire path for a directory -// that does not exist -func (s *Zookeeper) createFullPath(path []string, ephemeral bool) error { +// that does not exist and sets the value of the last +// znode to data +func (s *Zookeeper) createFullPath(path []string, data []byte, ephemeral bool) error { for i := 1; i <= len(path); i++ { newpath := "/" + strings.Join(path[:i], "/") - if i == len(path) && ephemeral { - _, err := s.client.Create(newpath, []byte{}, zk.FlagEphemeral, zk.WorldACL(zk.PermAll)) + + if i == len(path) { + flag := 0 + if ephemeral { + flag = zk.FlagEphemeral + } + _, err := s.client.Create(newpath, data, int32(flag), zk.WorldACL(zk.PermAll)) return err } + _, err := s.client.Create(newpath, []byte{}, 0, zk.WorldACL(zk.PermAll)) if err != nil { // Skip if node already exists @@ -121,13 +140,14 @@ func (s *Zookeeper) Put(key string, value []byte, opts *store.WriteOptions) erro if !exists { if opts != nil && opts.TTL > 0 { - s.createFullPath(store.SplitKey(strings.TrimSuffix(key, "/")), true) + s.createFullPath(store.SplitKey(strings.TrimSuffix(key, "/")), value, true) } else { - s.createFullPath(store.SplitKey(strings.TrimSuffix(key, "/")), false) + s.createFullPath(store.SplitKey(strings.TrimSuffix(key, "/")), value, false) } + } else { + _, err = s.client.Set(fkey, value, -1) } - _, err = s.client.Set(fkey, value, -1) return err } @@ -313,7 +333,7 @@ func (s *Zookeeper) AtomicPut(key string, value []byte, previous *store.KVPair, // Create the directory parts := store.SplitKey(strings.TrimSuffix(key, "/")) parts = parts[:len(parts)-1] - if err = s.createFullPath(parts, false); err != nil { + if err = s.createFullPath(parts, []byte{}, false); err != nil { // Failed to create the directory. return false, nil, err }