diff --git a/jobs/gorouter/spec b/jobs/gorouter/spec index b99da73bf..c6d96e75f 100644 --- a/jobs/gorouter/spec +++ b/jobs/gorouter/spec @@ -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 diff --git a/jobs/gorouter/templates/gorouter.yml.erb b/jobs/gorouter/templates/gorouter.yml.erb index eddeae6e9..3b5301394 100644 --- a/jobs/gorouter/templates/gorouter.yml.erb +++ b/jobs/gorouter/templates/gorouter.yml.erb @@ -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%> diff --git a/spec/gorouter_templates_spec.rb b/spec/gorouter_templates_spec.rb index 6f97620c9..01d3353fd 100644 --- a/spec/gorouter_templates_spec.rb +++ b/spec/gorouter_templates_spec.rb @@ -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, @@ -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