Browse Source

Migration to the new Etcd client

This commit migrates the old 'go-etcd' client, which is deprecated
to the new 'coreos/etcd/client'.

One notable change is the ability to specify an 'IsDir' parameter
to the 'Put' call. This allows to circumvent the limitations of etcd
regarding the key/directory distinction while setting up Watches on
a directory. A conservative measure to set up a watch that should be
used the same way for etcd/consul/zookeeper is to enforce the 'IsDir'
parameter with 'WriteOptions' on 'Put' to avoid the 'NotANode' error
thrown by etcd on Watch call. Consul and zookeeper are not using the
'IsDir' parameter.

Signed-off-by: Alexandre Beslic <abronan@docker.com>
Alexandre Beslic 9 years ago
parent
commit
2603af65e5
1 changed files with 3 additions and 2 deletions
  1. 3 2
      libnetwork/internal/kvstore/kvstore.go

+ 3 - 2
libnetwork/internal/kvstore/kvstore.go

@@ -46,7 +46,7 @@ type Config struct {
 }
 
 // ClientTLSConfig contains data for a Client TLS configuration in the form
-//  the etcd client wants it.  Eventually we'll adapt it for ZK and Consul.
+// the etcd client wants it.  Eventually we'll adapt it for ZK and Consul.
 type ClientTLSConfig struct {
 	CertFile   string
 	KeyFile    string
@@ -108,7 +108,8 @@ type KVPair struct {
 
 // WriteOptions contains optional request parameters
 type WriteOptions struct {
-	TTL time.Duration
+	IsDir bool
+	TTL   time.Duration
 }
 
 // LockOptions contains optional request parameters