Update libkv
- To commit id c2aac5dbbaa5c872211edea7c0f32b3bd67e7410 Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
c14ab8592e
commit
3cc33dc491
6 changed files with 26 additions and 1 deletions
2
libnetwork/Godeps/Godeps.json
generated
2
libnetwork/Godeps/Godeps.json
generated
|
@ -156,7 +156,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/libkv",
|
||||
"Rev": "749af6c5b3fb755bec1738cc5e0d3a6f1574d730"
|
||||
"Rev": "c2aac5dbbaa5c872211edea7c0f32b3bd67e7410"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/godbus/dbus",
|
||||
|
|
3
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/boltdb/boltdb.go
generated
vendored
3
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/boltdb/boltdb.go
generated
vendored
|
@ -330,6 +330,9 @@ func (b *BoltDB) AtomicDelete(key string, previous *store.KVPair) (bool, error)
|
|||
}
|
||||
|
||||
val = bucket.Get([]byte(key))
|
||||
if val == nil {
|
||||
return store.ErrKeyNotFound
|
||||
}
|
||||
dbIndex := binary.LittleEndian.Uint64(val[:libkvmetadatalen])
|
||||
if dbIndex != previous.LastIndex {
|
||||
return store.ErrKeyModified
|
||||
|
|
7
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/consul/consul.go
generated
vendored
7
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/consul/consul.go
generated
vendored
|
@ -467,6 +467,13 @@ func (s *Consul) AtomicDelete(key string, previous *store.KVPair) (bool, error)
|
|||
}
|
||||
|
||||
p := &api.KVPair{Key: s.normalize(key), ModifyIndex: previous.LastIndex}
|
||||
|
||||
// Extra Get operation to check on the key
|
||||
_, err := s.Get(key)
|
||||
if err != nil && err == store.ErrKeyNotFound {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if work, _, err := s.client.KV().DeleteCAS(p, nil); err != nil {
|
||||
return false, err
|
||||
} else if !work {
|
||||
|
|
4
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/etcd/etcd.go
generated
vendored
4
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/store/etcd/etcd.go
generated
vendored
|
@ -368,6 +368,10 @@ func (s *Etcd) AtomicDelete(key string, previous *store.KVPair) (bool, error) {
|
|||
_, err := s.client.Delete(context.Background(), s.normalize(key), delOpts)
|
||||
if err != nil {
|
||||
if etcdError, ok := err.(etcd.Error); ok {
|
||||
// Key Not Found
|
||||
if etcdError.Code == etcd.ErrorCodeKeyNotFound {
|
||||
return false, store.ErrKeyNotFound
|
||||
}
|
||||
// Compare failed
|
||||
if etcdError.Code == etcd.ErrorCodeTestFailed {
|
||||
return false, store.ErrKeyModified
|
||||
|
|
|
@ -347,9 +347,15 @@ func (s *Zookeeper) AtomicDelete(key string, previous *store.KVPair) (bool, erro
|
|||
|
||||
err := s.client.Delete(s.normalize(key), int32(previous.LastIndex))
|
||||
if err != nil {
|
||||
// Key not found
|
||||
if err == zk.ErrNoNode {
|
||||
return false, store.ErrKeyNotFound
|
||||
}
|
||||
// Compare failed
|
||||
if err == zk.ErrBadVersion {
|
||||
return false, store.ErrKeyModified
|
||||
}
|
||||
// General store error
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
|
|
5
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/testutils/utils.go
generated
vendored
5
libnetwork/Godeps/_workspace/src/github.com/docker/libkv/testutils/utils.go
generated
vendored
|
@ -312,6 +312,11 @@ func testAtomicDelete(t *testing.T, kv store.Store) {
|
|||
success, err = kv.AtomicDelete(key, pair)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, success)
|
||||
|
||||
// Delete a non-existent key; should fail
|
||||
success, err = kv.AtomicDelete(key, pair)
|
||||
assert.Error(t, store.ErrKeyNotFound)
|
||||
assert.False(t, success)
|
||||
}
|
||||
|
||||
func testLockUnlock(t *testing.T, kv store.Store) {
|
||||
|
|
Loading…
Add table
Reference in a new issue