Skip to content

Commit

Permalink
Merge pull request #159 from alphagov/configure-gorouter-configure-ke…
Browse files Browse the repository at this point in the history
…epalive-probe

Configure gorouter keep alive probe interval
  • Loading branch information
Clay Kauzlaric authored Oct 28, 2019
2 parents a5eb78a + 54f1a75 commit c38e805
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobs/gorouter/spec
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ properties:
router.max_idle_connections:
default: 100
description: "Maximum idle keepalive connections per backend. This value can only between 0 and 100. When 0, support for keepalive connections is disabled."
router.keep_alive_probe_interval:
default: 1s
description: Interval between TCP keep alive probes. Value is a string (e.g. "10s")
router.force_forwarded_proto_https:
description: "Enables setting X-Forwarded-Proto header if SSL termination happened upstream and incorrectly set the header value. When this property is set to true gorouter sets the header X-Forwarded-Proto to https. When this value set to false, gorouter set the header X-Forwarded-Proto to the protocol of the incoming request"
default: false
Expand Down
1 change: 1 addition & 0 deletions jobs/gorouter/templates/gorouter.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ route_latency_metric_muzzle_duration: 30s
disable_keep_alives: false
max_idle_conns: <%= p("router.max_idle_connections") %>
max_idle_conns_per_host: 100
endpoint_keep_alive_probe_interval: <%= p("router.keep_alive_probe_interval") %>
<% else %>
disable_keep_alives: true
<% end%>
Expand Down
49 changes: 49 additions & 0 deletions spec/gorouter_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
'sanitize_forwarded_proto' => false,
'suspend_pruning_if_nats_unavailable' => false,
'max_idle_connections' => 100,
'keep_alive_probe_interval' => '1s',
'prune_all_stale_routes' => false,
'backends' => {
'max_conns' => 100,
Expand Down Expand Up @@ -141,6 +142,54 @@
subject(:parsed_yaml) { YAML.safe_load(rendered_template) }

context 'given a generally valid manifest' do
describe 'keep alives' do
context 'max_idle_connections is set' do
context 'using default values' do
it 'should not disable keep alives' do
expect(parsed_yaml['disable_keep_alives']).to eq(false)
end
it 'should set endpoint_keep_alive_probe_interval' do
expect(parsed_yaml['endpoint_keep_alive_probe_interval']).to eq('1s')
end
it 'should set max_idle_conns' do
expect(parsed_yaml['max_idle_conns']).to eq(100)
expect(parsed_yaml['max_idle_conns_per_host']).to eq(100)
end
end
context 'using custom values' do
before do
deployment_manifest_fragment['router']['max_idle_connections'] = 2500
deployment_manifest_fragment['router']['keep_alive_probe_interval'] = '500ms'
end
it 'should not disable keep alives' do
expect(parsed_yaml['disable_keep_alives']).to eq(false)
end
it 'should set endpoint_keep_alive_probe_interval' do
expect(parsed_yaml['endpoint_keep_alive_probe_interval']).to eq('500ms')
end
it 'should set max_idle_conns' do
expect(parsed_yaml['max_idle_conns']).to eq(2500)
expect(parsed_yaml['max_idle_conns_per_host']).to eq(100)
end
end
end

context 'max_idle_connections is not set' do
before do
deployment_manifest_fragment['router']['max_idle_connections'] = 0
end
it 'should disable keep alives' do
expect(parsed_yaml['disable_keep_alives']).to eq(true)
end
it 'should not set endpoint_keep_alive_probe_interval' do
expect(parsed_yaml['endpoint_keep_alive_probe_interval']).to eq(nil)
end
it 'should not set max_idle_conns' do
expect(parsed_yaml['max_idle_conns']).to eq(nil)
expect(parsed_yaml['max_idle_conns_per_host']).to eq(nil)
end
end
end
describe 'sticky_session_cookies' do
context 'when no value is provided' do
it 'should use JSESSIONID' do
Expand Down

0 comments on commit c38e805

Please sign in to comment.