Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure gorouter keep alive probe interval #159

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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