diff --git a/coordination/etcdtest/fake_etcd.go b/coordination/etcdtest/fake_etcd.go index b82eca0caf36dd9348a63f941b6989d7324e2446..6cf02c287abc22ed1b23e14d11d44544067d9d1a 100644 --- a/coordination/etcdtest/fake_etcd.go +++ b/coordination/etcdtest/fake_etcd.go @@ -200,7 +200,7 @@ func (s *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, err return s.trigger("set", key), nil } -func (s *FakeEtcdClient) SetDir(key string, ttl uint64) (*etcd.Response, error) { +func (s *FakeEtcdClient) CreateDir(key string, ttl uint64) (*etcd.Response, error) { // TODO. There are no directories. return &etcd.Response{}, nil } diff --git a/coordination/presence/presence.go b/coordination/presence/presence.go index 7c11c5b1d3957c98092ed3297e905505a1c88fc9..41c95864a356950fee6b9e5dac2a2904fc463b12 100644 --- a/coordination/presence/presence.go +++ b/coordination/presence/presence.go @@ -1,7 +1,6 @@ package presence import ( - "fmt" "log" "time" @@ -12,10 +11,10 @@ import ( type EtcdClient interface { AddChild(key string, value string, ttl uint64) (*etcd.Response, error) Create(key string, value string, ttl uint64) (*etcd.Response, error) + CreateDir(key string, ttl uint64) (*etcd.Response, error) Update(key string, value string, ttl uint64) (*etcd.Response, error) Delete(key string, recursive bool) (*etcd.Response, error) Get(key string, sort, recursive bool) (*etcd.Response, error) - SetDir(key string, ttl uint64) (*etcd.Response, error) } // A Client can read the list of active nodes written by Presence workers. @@ -77,10 +76,8 @@ func (p *Presence) Stop() { // Start the presence worker. func (p *Presence) Start() error { - // Create the presence directory if it does not exist. - if _, err := p.client.SetDir(p.path, 0); err != nil { - return fmt.Errorf("could not create presence directory: %v", err) - } + // Create the presence directory if it does not exist. Ignore errors. + p.client.CreateDir(p.path, 0) go p.run() return nil diff --git a/etcd_client.go b/etcd_client.go index 51208436bc86a4462b248bb93e135467f46e83bc..ab18aa3d5b481fd7c6b19eebb5de59ef6367bcd2 100644 --- a/etcd_client.go +++ b/etcd_client.go @@ -90,11 +90,11 @@ func NewEtcdClient(strongReads bool) EtcdClient { type EtcdClient interface { AddChild(string, string, uint64) (*etcd.Response, error) Create(string, string, uint64) (*etcd.Response, error) + CreateDir(string, uint64) (*etcd.Response, error) CompareAndSwap(string, string, uint64, string, uint64) (*etcd.Response, error) Delete(string, bool) (*etcd.Response, error) Get(string, bool, bool) (*etcd.Response, error) Set(string, string, uint64) (*etcd.Response, error) - SetDir(string, uint64) (*etcd.Response, error) Update(string, string, uint64) (*etcd.Response, error) Watch(string, uint64, bool, chan *etcd.Response, chan bool) (*etcd.Response, error) }