Skip to content

Commit

Permalink
fix: Don't retry more often than endpoints available (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
domdom82 authored Feb 29, 2024
1 parent be5ea2f commit 112f971
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion jobs/gorouter/spec
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ properties:
router.backends.max_attempts:
description: |
Maximum number of attempts on failing requests against backend routes.
The number of attempts per request is limited by the number of endpoints on the route, regardless of this setting.
This includes CF apps and route-registrar endpoints.
A value of 0 implies indefinite retries, i.e. retry until success or endpoint list is exhausted.
The minimum value for this setting is 1. This prevents gorouter from getting blocked by indefinite retries.
default: 3
router.backends.ca:
description: Certificate authority that was used to sign certificates for TLS-registered backends. In PEM format.
Expand Down
4 changes: 2 additions & 2 deletions jobs/gorouter/templates/gorouter.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ end
backend_attempts = 3
if_p('router.backends.max_attempts') { |val| backend_attempts = val }

if (backend_attempts < 0 )
raise 'router.backends.max_attempts cannot be negative'
if (backend_attempts < 1 )
raise 'router.backends.max_attempts must maintain a minimum value of 1'
end

backends = {
Expand Down
6 changes: 3 additions & 3 deletions spec/gorouter_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,16 @@
before do
deployment_manifest_fragment['router']['backends']['max_attempts'] = 0
end
it 'should configure the property with indefinite retries' do
expect(parsed_yaml['backends']['max_attempts']).to eq(0)
it 'should error' do
expect { raise parsed_yaml }.to raise_error(RuntimeError, 'router.backends.max_attempts must maintain a minimum value of 1')
end
end
context 'when max_attempts is negative' do
before do
deployment_manifest_fragment['router']['backends']['max_attempts'] = -1
end
it 'should error' do
expect { raise parsed_yaml }.to raise_error(RuntimeError, 'router.backends.max_attempts cannot be negative')
expect { raise parsed_yaml }.to raise_error(RuntimeError, 'router.backends.max_attempts must maintain a minimum value of 1')
end
end
context 'when both cert_chain and private_key are provided' do
Expand Down

0 comments on commit 112f971

Please sign in to comment.