Correct way to watch a etcd directory

684 views
Skip to first unread message

Joji Mekkatt

unread,
Jan 30, 2016, 10:21:17 PM1/30/16
to etcd-dev
I have an application that needs to watch a service directory for any membership changes.
When I start the application, I first read the directory to get the current state.
Now I initiate a Watch on the directory, with the watch index set to dirNode.ModifiedIndex + 1.

However, if I restart the application after some time (of the order of an hour), I get the following error from
the Watch routine:

Err: 401: The event in requested index is outdated and cleared (the requested history has been cleared [19629/11965]) [20628]"

curl http://127.0.0.1:2379/v2/keys/contiv.io/service/netmaster
{"action":"get","node":{"key":"/contiv.io/service/netmaster","dir":true,"nodes":[{"key":"/contiv.io/service/netmaster/k8master:9999","value":"{\"ServiceName\":\"netmaster\",\"HostAddr\":\"k8master\",\"Port\":9999}","expiration":"2016-01-31T03:18:49.736189948Z","ttl":41,"modifiedIndex":22040,"createdIndex":11964}],"modifiedIndex":11964,"createdIndex":11964}}

Why am I getting this error? Am I supposed to pass a different watch index?

Any ideas/suggestions appreciated.

Thanks,
Joji.

Joji Mekkatt

unread,
Jan 31, 2016, 1:03:44 AM1/31/16
to etcd-dev
Looks like I need to use X-Etcd-Index per https://github.com/coreos/etcd/blob/master/Documentation/api.md.
Reply all
Reply to author
Forward
0 new messages