From bebefd8b80acb92ccfb34d2bc3bd1c723a700252 Mon Sep 17 00:00:00 2001 From: spacewander Date: Tue, 16 Aug 2022 11:33:01 +0800 Subject: [PATCH 1/2] chore: log when an invalid watch request is received As protobuf doesn't have required field, user may send an empty WatchRequest by mistake. Currently, etcd will ignore the invalid request and keep the stream opening. If we don't reject the invalid request by closing the stream, it would be better to leave a log there. This commit also fixes a typo in the comment. Signed-off-by: spacewander --- server/etcdserver/api/v3rpc/watch.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/etcdserver/api/v3rpc/watch.go b/server/etcdserver/api/v3rpc/watch.go index 00b68cdbf0a..abd9b99a7e0 100644 --- a/server/etcdserver/api/v3rpc/watch.go +++ b/server/etcdserver/api/v3rpc/watch.go @@ -346,8 +346,9 @@ func (sws *serverWatchStream) recvLoop() error { } default: // we probably should not shutdown the entire stream when - // receive an valid command. + // receive an invalid command. // so just do nothing instead. + sws.lg.Warn("invalid watch request received in gRPC stream") continue } } From 508ce517e0751fae63664070d83c57cc010ea008 Mon Sep 17 00:00:00 2001 From: spacewander Date: Wed, 17 Aug 2022 09:25:37 +0800 Subject: [PATCH 2/2] update according to the review Signed-off-by: spacewander --- server/etcdserver/api/v3rpc/watch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/etcdserver/api/v3rpc/watch.go b/server/etcdserver/api/v3rpc/watch.go index abd9b99a7e0..1a3cff539f6 100644 --- a/server/etcdserver/api/v3rpc/watch.go +++ b/server/etcdserver/api/v3rpc/watch.go @@ -348,7 +348,7 @@ func (sws *serverWatchStream) recvLoop() error { // we probably should not shutdown the entire stream when // receive an invalid command. // so just do nothing instead. - sws.lg.Warn("invalid watch request received in gRPC stream") + sws.lg.Sugar().Infof("invalid watch request type %T received in gRPC stream", uv) continue } }