From 7c1b69cbeb39018d61f4466d69e756d9aa108137 Mon Sep 17 00:00:00 2001 From: Pierre Souchay Date: Fri, 8 Jan 2021 21:23:23 +0100 Subject: [PATCH] Display a warning when rpc.enable_streaming = true is set on a client (#9530) * Display a warning when rpc.enable_streaming = true is set on a client This option has no effect when running as an agent * Added warning when server starts with use_streaming_backend but without rpc.enable_streaming * Added unit test --- .changelog/9530.txt | 3 +++ agent/config/builder.go | 8 +++++++ agent/config/runtime_test.go | 42 ++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .changelog/9530.txt diff --git a/.changelog/9530.txt b/.changelog/9530.txt new file mode 100644 index 0000000000..96816211d5 --- /dev/null +++ b/.changelog/9530.txt @@ -0,0 +1,3 @@ +```release-note:improvement +streaming: display a warning on agent(s) when incompatible streaming parameters are used +``` diff --git a/agent/config/builder.go b/agent/config/builder.go index 89a569e9fd..48cdd3d0cc 100644 --- a/agent/config/builder.go +++ b/agent/config/builder.go @@ -1426,6 +1426,14 @@ func (b *Builder) Validate(rt RuntimeConfig) error { b.warn("bootstrap_expect > 0: expecting %d servers", rt.BootstrapExpect) } + if rt.ServerMode { + if rt.UseStreamingBackend && !rt.RPCConfig.EnableStreaming { + b.warn("use_streaming_backend = true requires rpc.enable_streaming on servers to work properly") + } + } else if rt.RPCConfig.EnableStreaming { + b.warn("rpc.enable_streaming = true has no effect when not running in server mode") + } + if rt.AutoEncryptAllowTLS { if !rt.VerifyIncoming && !rt.VerifyIncomingRPC { b.warn("if auto_encrypt.allow_tls is turned on, either verify_incoming or verify_incoming_rpc should be enabled. It is necessary to turn it off during a migration to TLS, but it should definitely be turned on afterwards.") diff --git a/agent/config/runtime_test.go b/agent/config/runtime_test.go index 1f441473d8..48d10321d5 100644 --- a/agent/config/runtime_test.go +++ b/agent/config/runtime_test.go @@ -2898,6 +2898,48 @@ func TestBuilder_BuildAndValidate_ConfigFlagsAndEdgecases(t *testing.T) { rt.SkipLeaveOnInt = true }, }, + { + desc: "rpc.enable_streaming = true has no effect when not running in server mode", + args: []string{ + `-data-dir=` + dataDir, + }, + json: []string{`{ + "rpc": { "enable_streaming": true } + }`}, + hcl: []string{` + rpc { enable_streaming = true } + `}, + warns: []string{"rpc.enable_streaming = true has no effect when not running in server mode"}, + patch: func(rt *RuntimeConfig) { + rt.DataDir = dataDir + // rpc.enable_streaming make no sense in not-server mode + rt.RPCConfig.EnableStreaming = true + rt.ServerMode = false + }, + }, + { + desc: "use_streaming_backend = true requires rpc.enable_streaming on servers to work properly", + args: []string{ + `-data-dir=` + dataDir, + }, + json: []string{`{ + "use_streaming_backend": true, + "server": true + }`}, + hcl: []string{` + use_streaming_backend = true + server = true + `}, + warns: []string{"use_streaming_backend = true requires rpc.enable_streaming on servers to work properly"}, + patch: func(rt *RuntimeConfig) { + rt.DataDir = dataDir + rt.UseStreamingBackend = true + // server things + rt.ServerMode = true + rt.LeaveOnTerm = false + rt.SkipLeaveOnInt = true + }, + }, { desc: "auto_encrypt.allow_tls errors in client mode", args: []string{