Skip to content

Commit

Permalink
refactor: rename lb_algo to loadbalancing
Browse files Browse the repository at this point in the history
  • Loading branch information
a18e authored and ameowlia committed Jan 9, 2025
1 parent 6200f03 commit 023743b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions jobs/route_registrar/spec
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ properties:
writable (optional, boolean): sets the writable flag. defaults to false

options object
lb_algo (optional, string): Load balancing algorithm for routing incoming requests to the backend: 'round-robin' or 'least-connection'. In cases where this option is not specified, the algorithm defined in gorouter spec is applied.
loadbalancing (optional, string): Load balancing algorithm for routing incoming requests to the backend: 'round-robin' or 'least-connection'. In cases where this option is not specified, the algorithm defined in gorouter spec is applied.

example: |
- name: my-service
Expand All @@ -162,7 +162,7 @@ properties:
timeout: 5s
route_service_url: https://my-oauth-proxy-route-service.example.com
options:
lb_algo: least-connection
loadbalancing: least-connection
- name: my-tls-endpoint
tls_port: 12346
server_cert_domain_san: "my-tls-endpoint.internal.com"
Expand Down
4 changes: 2 additions & 2 deletions jobs/route_registrar/templates/registrar_settings.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ TEXT
end

if route['options'] != nil
if (route['options']['lb_algo'] != nil && route['options']['lb_algo'] != 'least-connection' && route['options']['lb_algo'] != 'round-robin')
raise "expected route_registrar.routes[#{index}].route.options.lb_algo to be least-connection or round-robin when provided"
if (route['options']['loadbalancing'] != nil && route['options']['loadbalancing'] != 'least-connection' && route['options']['loadbalancing'] != 'round-robin')
raise "expected route_registrar.routes[#{index}].route.options.loadbalancing to be least-connection or round-robin when provided"
end
end

Expand Down
22 changes: 11 additions & 11 deletions spec/route_registar_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -722,24 +722,24 @@
merged_manifest_properties['route_registrar']['routes'][0]['options'] = {}
end

it 'uses configured round-robin lb_algo' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['lb_algo'] = 'round-robin'
it 'uses configured round-robin loadbalancing' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['loadbalancing'] = 'round-robin'
rendered_hash = JSON.parse(template.render(merged_manifest_properties, consumes: links))
expect(rendered_hash['routes'][0]['options']['lb_algo']).to eq('round-robin')
expect(rendered_hash['routes'][0]['options']['loadbalancing']).to eq('round-robin')
end
it 'uses configured least-connection lb_algo' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['lb_algo'] = 'least-connection'
it 'uses configured least-connection loadbalancing' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['loadbalancing'] = 'least-connection'
rendered_hash = JSON.parse(template.render(merged_manifest_properties, consumes: links))
expect(rendered_hash['routes'][0]['options']['lb_algo']).to eq('least-connection')
expect(rendered_hash['routes'][0]['options']['loadbalancing']).to eq('least-connection')
end
it 'without lb_algo' do
it 'without loadbalancing' do
rendered_hash = JSON.parse(template.render(merged_manifest_properties, consumes: links))
expect(rendered_hash['routes'][0]['options']['lb_algo']).to be nil
expect(rendered_hash['routes'][0]['options']['loadbalancing']).to be nil
end
it 'raises error for unknown lb_algo' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['lb_algo'] = 'unknown'
it 'raises error for unknown loadbalancing' do
merged_manifest_properties['route_registrar']['routes'][0]['options']['loadbalancing'] = 'unknown'
expect { template.render(merged_manifest_properties, consumes: links) }.to raise_error(
RuntimeError, 'expected route_registrar.routes[0].route.options.lb_algo to be least-connection or round-robin when provided'
RuntimeError, 'expected route_registrar.routes[0].route.options.loadbalancing to be least-connection or round-robin when provided'
)
end
end
Expand Down

0 comments on commit 023743b

Please sign in to comment.