etcd icon indicating copy to clipboard operation
etcd copied to clipboard

Watch channel return immediately if revision is very large

Open hongchaodeng opened this issue 10 years ago • 6 comments

I had encountered an unexpected scenario:

  • watch from, say rev:100, where the rev of etcd is < 10.
  • the watch response channel return immediately with empty response

Is it unexpected? I figure that it should wait until some change with later rev happens.

hongchaodeng avatar Feb 26 '16 06:02 hongchaodeng

@hongchaodeng etcd does not accept future revision. What is the use case for waiting for a future revision? I know etcd2 support that, but I really cannot think of a valid use case.

xiang90 avatar Feb 26 '16 06:02 xiang90

/cc @heyitsanthony

xiang90 avatar Feb 26 '16 06:02 xiang90

the watch response channel return immediately with empty response

Also, you should always do resp,ok:= <-ch. When there is an error, client will close the chan.

xiang90 avatar Feb 26 '16 06:02 xiang90

See this: https://github.com/kubernetes/kubernetes/blob/c5260c8c7133d84f903d41a32ef6562c6c69e762/pkg/storage/etcd/etcd_watcher.go#L186

I want to get changes after specific rev:

    opts := etcd.WatcherOptions{
            Recursive:  w.list,
            AfterIndex: resourceVersion,
        }

hongchaodeng avatar Feb 26 '16 06:02 hongchaodeng

@hongchaodeng the way I've been doing it is open a watcher wch on resourceVersion, drop the first event, then the rest of the stream is greater than resourceVersion

heyitsanthony avatar Feb 26 '16 06:02 heyitsanthony

@magicwang-cn

magicwang-cn avatar Mar 02 '16 02:03 magicwang-cn