From 4cfc6a0ed608c4ff7a1c40ca7c1dabda17962e6a Mon Sep 17 00:00:00 2001 From: Charlie Voiselle <464492+angrycub@users.noreply.github.com> Date: Mon, 1 Nov 2021 16:30:53 -0400 Subject: [PATCH] Making RPC Upgrade mode reloadable. (#11144) - Making RPC Upgrade mode reloadable. - Add suggestions from code review - remove spurious comment - switch to require(t,...) form for test. - Add to changelog --- .changelog/11144.txt | 3 +++ command/agent/agent.go | 4 ++++ command/agent/agent_test.go | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 .changelog/11144.txt diff --git a/.changelog/11144.txt b/.changelog/11144.txt new file mode 100644 index 00000000000..b0a5f567fa1 --- /dev/null +++ b/.changelog/11144.txt @@ -0,0 +1,3 @@ +```release-note:improvement +agent: Added `tls -> rpc_upgrade_mode` to be reloaded on SIGHUP +``` diff --git a/command/agent/agent.go b/command/agent/agent.go index ae373c86d10..b070de55596 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -1098,6 +1098,10 @@ func (a *Agent) ShouldReload(newConfig *Config) (agent, http bool) { agent = true } + if a.config.TLSConfig.RPCUpgradeMode != newConfig.TLSConfig.RPCUpgradeMode { + agent = true + } + return agent, http } diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 0182ca26429..f1a834cd4ed 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -1296,6 +1296,27 @@ func TestServer_ShouldReload_ShouldHandleMultipleChanges(t *testing.T) { } } +func TestServer_ShouldReload_ReturnTrueForRPCUpgradeModeChanges(t *testing.T) { + t.Parallel() + + sameAgentConfig := &Config{ + TLSConfig: &config.TLSConfig{ + RPCUpgradeMode: true, + }, + } + + agent := NewTestAgent(t, t.Name(), func(c *Config) { + c.TLSConfig = &config.TLSConfig{ + RPCUpgradeMode: false, + } + }) + defer agent.Shutdown() + + shouldReloadAgent, shouldReloadHTTP := agent.ShouldReload(sameAgentConfig) + require.True(t, shouldReloadAgent) + require.False(t, shouldReloadHTTP) +} + func TestAgent_ProxyRPC_Dev(t *testing.T) { t.Parallel() agent := NewTestAgent(t, t.Name(), nil)