Skip to content

Commit

Permalink
Remove option ignore_weights so weights will be used by default and c…
Browse files Browse the repository at this point in the history
…hange log level for duplicate weights.
  • Loading branch information
minkovich authored and Tiffany Low committed May 27, 2016
1 parent 2e0c6f2 commit 6d9b95a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/synapse/haproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ def initialize(opts)
@opts['do_writes'] = true unless @opts.key?('do_writes')
@opts['do_socket'] = true unless @opts.key?('do_socket')
@opts['do_reloads'] = true unless @opts.key?('do_reloads')
@opts['ignore_weights'] = true unless @opts.key?('ignore_weights')

# how to restart haproxy
@restart_interval = @opts.fetch('restart_interval', 2).to_i
Expand Down Expand Up @@ -749,10 +748,10 @@ def generate_backend_stanza(watcher, config)
end
end
b = "#{b} #{watcher.haproxy['server_options']}" if watcher.haproxy['server_options']
if !@opts['ignore_weights'] && backend.has_key?('weight')
if backend.has_key?('weight')
# Check if server_options already contains weight, is so log a warning
if watcher.haproxy['server_options'].include? 'weight'
log.info "synapse: weight is defined by server_options and by nerve"
log.warn "synapse: weight is defined by server_options and by nerve"
end
weight = backend['weight'].to_i
b = "#{b} weight #{weight}"
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/synapse/service_watcher_base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def remove_arg(name)
end
end

context 'with ignore_weights set to false' do
context 'with weights defined' do
let(:backends_with_weight) { [
{ 'name' => 'server1', 'host' => 'server1', 'port' => 1111, 'weight' => 11 },
{ 'name' => 'server2', 'host' => 'server2', 'port' => 2222, 'weight' => 22 },
Expand Down
1 change: 0 additions & 1 deletion spec/support/minimum.conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ haproxy:
config_file_path: "/etc/haproxy/haproxy.cfg"
do_writes: false
do_reloads: false
ignore_weights: false
global:
- global_test_option

Expand Down

0 comments on commit 6d9b95a

Please sign in to comment.