Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/synapse/haproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def generate_backend_stanza(watcher, config)
config.map {|c| "\t#{c}"},
watcher.backends.shuffle.map {|backend|
backend_name = construct_name(backend)
"\tserver #{backend_name} #{backend['host']}:#{backend['port']} " \
"\tserver #{backend_name} #{backend['host']}:#{backend['port']} #{' backup' if backend['backup']} " \
"cookie #{backend_name} #{watcher.haproxy['server_options']}" }
]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/synapse/service_watcher/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def ping?
def backends
if @leader_election
if @backends.all?{|b| b.key?('id') && b['id']}
smallest = @backends.sort_by{ |b| b['id']}.first
@backends.sort_by{ |b| b['id']}.first['backup'] = false
log.debug "synapse: leader election chose one of #{@backends.count} backends " \
"(#{smallest['host']}:#{smallest['port']} with id #{smallest['id']})"

return [smallest]
return @backends
elsif (Time.now - @leader_last_warn) > LEADER_WARN_INTERVAL
log.warn "synapse: service #{@name}: leader election failed; not all backends include an id"
@leader_last_warn = Time.now
Expand Down
2 changes: 1 addition & 1 deletion lib/synapse/service_watcher/zookeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def discover
numeric_id = NUMBERS_RE =~ numeric_id ? numeric_id.to_i : nil

log.debug "synapse: discovered backend #{name} at #{host}:#{server_port} for service #{@name}"
new_backends << { 'name' => name, 'host' => host, 'port' => server_port, 'id' => numeric_id}
new_backends << { 'name' => name, 'host' => host, 'port' => server_port, 'id' => numeric_id, 'backup' => @leader_election}
end
end

Expand Down