Skip to content

Commit

Permalink
Making RPC Upgrade mode reloadable.
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycub committed Sep 7, 2021
1 parent 53bf28f commit 23a8638
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,11 @@ func (a *Agent) ShouldReload(newConfig *Config) (agent, http bool) {
agent = true
}

// Allow the ability to only reload HTTP connections
if a.config.TLSConfig.RPCUpgradeMode != newConfig.TLSConfig.RPCUpgradeMode {
agent = true
}

return agent, http
}

Expand Down
42 changes: 42 additions & 0 deletions command/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,48 @@ func TestServer_ShouldReload_ShouldHandleMultipleChanges(t *testing.T) {
}
}

func TestServer_ShouldReload_ReturnTrueForRPCUpgradeModeChanges(t *testing.T) {
t.Parallel()
assert := assert.New(t)

const (
cafile = "../../helper/tlsutil/testdata/ca.pem"
foocert = "../../helper/tlsutil/testdata/nomad-foo.pem"
fookey = "../../helper/tlsutil/testdata/nomad-foo-key.pem"
)
dir := tmpDir(t)
defer os.RemoveAll(dir)

sameAgentConfig := &Config{
TLSConfig: &config.TLSConfig{
EnableHTTP: true,
EnableRPC: true,
VerifyServerHostname: true,
CAFile: cafile,
CertFile: foocert,
KeyFile: fookey,
RPCUpgradeMode: true,
},
}

agent := NewTestAgent(t, t.Name(), func(c *Config) {
c.TLSConfig = &config.TLSConfig{
EnableHTTP: true,
EnableRPC: true,
VerifyServerHostname: true,
CAFile: cafile,
CertFile: foocert,
KeyFile: fookey,
RPCUpgradeMode: false,
}
})
defer agent.Shutdown()

shouldReloadAgent, shouldReloadHTTP := agent.ShouldReload(sameAgentConfig)
assert.True(shouldReloadAgent)
assert.False(shouldReloadHTTP)
}

func TestAgent_ProxyRPC_Dev(t *testing.T) {
t.Parallel()
agent := NewTestAgent(t, t.Name(), nil)
Expand Down

0 comments on commit 23a8638

Please sign in to comment.