From d44f7d5f67284d9c060a4c01ff7c114dc4ccb005 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 9 Oct 2017 13:19:30 -0700 Subject: [PATCH] etcdctl/ctlv3: enable 'require-leader' for 'watch' command To help with network partition cases. Signed-off-by: Gyu-Ho Lee --- etcdctl/ctlv3/command/watch_command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etcdctl/ctlv3/command/watch_command.go b/etcdctl/ctlv3/command/watch_command.go index 4adf547e9cd..33edaf28a30 100644 --- a/etcdctl/ctlv3/command/watch_command.go +++ b/etcdctl/ctlv3/command/watch_command.go @@ -125,7 +125,7 @@ func getWatchChan(c *clientv3.Client, args []string) (clientv3.WatchChan, error) if watchPrevKey { opts = append(opts, clientv3.WithPrevKV()) } - return c.Watch(context.TODO(), key, opts...), nil + return c.Watch(clientv3.WithRequireLeader(context.Background()), key, opts...), nil } func printWatchCh(ch clientv3.WatchChan) {