Skip to content

Commit

Permalink
Making RPC Upgrade mode reloadable. (#11144)
Browse files Browse the repository at this point in the history
- Making RPC Upgrade mode reloadable.
- Add suggestions from code review
- remove spurious comment
- switch to require(t,...) form for test.
- Add to changelog
  • Loading branch information
angrycub authored Nov 1, 2021
1 parent ffa4d07 commit 4cfc6a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/11144.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
agent: Added `tls -> rpc_upgrade_mode` to be reloaded on SIGHUP
```
4 changes: 4 additions & 0 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
21 changes: 21 additions & 0 deletions command/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4cfc6a0

Please sign in to comment.