From 72b8f80dc3ef43b881f84050b35c5ef5a94867c2 Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Tue, 13 Oct 2015 10:43:52 -0700 Subject: [PATCH] Ensure the parent directory for key prefix exists Currently we are trying to ensure that the parent directory exists as a key. But it is really a directory and etcd expects it to be a directory. So made the change to ensure that the parent key is created as a directory and not as a simple key. Signed-off-by: Jana Radhakrishnan --- libnetwork/datastore/datastore.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libnetwork/datastore/datastore.go b/libnetwork/datastore/datastore.go index 027fe48df3..200f5709d6 100644 --- a/libnetwork/datastore/datastore.go +++ b/libnetwork/datastore/datastore.go @@ -385,15 +385,15 @@ func (ds *datastore) GetObject(key string, o KVObject) error { return nil } -func (ds *datastore) ensureKey(key string) error { - exists, err := ds.store.Exists(key) +func (ds *datastore) ensureParent(parent string) error { + exists, err := ds.store.Exists(parent) if err != nil { return err } if exists { return nil } - return ds.store.Put(key, []byte{}, nil) + return ds.store.Put(parent, []byte{}, &store.WriteOptions{IsDir: true}) } func (ds *datastore) List(key string, kvObject KVObject) ([]KVObject, error) { @@ -411,7 +411,7 @@ func (ds *datastore) List(key string, kvObject KVObject) ([]KVObject, error) { } // Make sure the parent key exists - if err := ds.ensureKey(key); err != nil { + if err := ds.ensureParent(key); err != nil { return nil, err }