diff --git a/libnetwork/internal/kvstore/boltdb/boltdb.go b/libnetwork/internal/kvstore/boltdb/boltdb.go index 94d01b4b09..bd1b5b7d22 100644 --- a/libnetwork/internal/kvstore/boltdb/boltdb.go +++ b/libnetwork/internal/kvstore/boltdb/boltdb.go @@ -381,7 +381,7 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt // doesn't exist in the DB. val = bucket.Get([]byte(key)) if previous == nil && len(val) != 0 { - return store.ErrKeyModified + return store.ErrKeyExists } if previous != nil { if len(val) == 0 { diff --git a/libnetwork/internal/kvstore/kvstore.go b/libnetwork/internal/kvstore/kvstore.go index 0df01b6c83..22b0ce4037 100644 --- a/libnetwork/internal/kvstore/kvstore.go +++ b/libnetwork/internal/kvstore/kvstore.go @@ -35,6 +35,8 @@ var ( ErrKeyNotFound = errors.New("Key not found in store") // ErrPreviousNotSpecified is thrown when the previous value is not specified for an atomic operation ErrPreviousNotSpecified = errors.New("Previous K/V pair should be provided for the Atomic operation") + // ErrKeyExists is thrown when the previous value exists in the case of an AtomicPut + ErrKeyExists = errors.New("Previous K/V pair exists, cannnot complete Atomic operation") ) // Config contains the options for a storage client