Skip to content

Commit c3bcd29

Browse files
committed
Remove option ignore_weights so weights will be used by default and change log level for duplicate weights.
1 parent d5ea7b0 commit c3bcd29

File tree

4 files changed

+3
-6
lines changed

4 files changed

+3
-6
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ This section is its own hash, which should contain the following keys:
261261
* `listen`: these lines will be parsed and placed in the correct `frontend`/`backend` section as applicable; you can put lines which are the same for the frontend and backend here.
262262
* `backend_order`: optional: how backends should be ordered in the `backend` stanza. (default is shuffling). Setting to `asc` means sorting backends in ascending alphabetical order before generating stanza. `desc` means descending alphabetical order. `no_shuffle` means no shuffling or sorting.
263263
* `shared_frontend`: optional: haproxy configuration directives for a shared http frontend (see below)
264-
* `ignore_weights`: optional: stops haproxy backend 'weight' options being generated, even if the Nerve registrations contain this information. This will cause all backend servers to be treated equally by haproxy. This defaults to true so weights will *NOT* be used by default.
265264

266265
<a name="haproxy"/>
267266
### Configuring HAProxy ###

lib/synapse/haproxy.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def initialize(opts)
535535
@opts['do_writes'] = true unless @opts.key?('do_writes')
536536
@opts['do_socket'] = true unless @opts.key?('do_socket')
537537
@opts['do_reloads'] = true unless @opts.key?('do_reloads')
538-
@opts['ignore_weights'] = true unless @opts.key?('ignore_weights')
539538

540539
# how to restart haproxy
541540
@restart_interval = @opts.fetch('restart_interval', 2).to_i
@@ -743,10 +742,10 @@ def generate_backend_stanza(watcher, config)
743742
b = "\tserver #{backend_name} #{backend['host']}:#{backend['port']}"
744743
b = "#{b} cookie #{backend_name}" unless config.include?('mode tcp')
745744
b = "#{b} #{watcher.haproxy['server_options']}" if watcher.haproxy['server_options']
746-
if !@opts['ignore_weights'] && backend.has_key?('weight')
745+
if backend.has_key?('weight')
747746
# Check if server_options already contains weight, is so log a warning
748747
if watcher.haproxy['server_options'].include? 'weight'
749-
log.info "synapse: weight is defined by server_options and by nerve"
748+
log.warn "synapse: weight is defined by server_options and by nerve"
750749
end
751750
weight = backend['weight'].to_i
752751
b = "#{b} weight #{weight}"

spec/lib/synapse/service_watcher_base_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def remove_arg(name)
136136
end
137137
end
138138

139-
context 'with ignore_weights set to false' do
139+
context 'with weights defined' do
140140
let(:backends_with_weight) { [
141141
{ 'name' => 'server1', 'host' => 'server1', 'port' => 1111, 'weight' => 11 },
142142
{ 'name' => 'server2', 'host' => 'server2', 'port' => 2222, 'weight' => 22 },

spec/support/minimum.conf.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ haproxy:
2020
config_file_path: "/etc/haproxy/haproxy.cfg"
2121
do_writes: false
2222
do_reloads: false
23-
ignore_weights: false
2423
global:
2524
- global_test_option
2625

0 commit comments

Comments
 (0)