From cd2ea63b7fd746defad09e1ee12bfd40110245e7 Mon Sep 17 00:00:00 2001 From: Joseph Lynch Date: Wed, 22 Jul 2015 20:55:52 -0700 Subject: [PATCH] Address feedback from igor and schleyfox Adds a comment about when we write out the file output and restored random backend ordering. --- lib/synapse/file_output.rb | 3 +++ lib/synapse/haproxy.rb | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/synapse/file_output.rb b/lib/synapse/file_output.rb index 369325b5..7f8c6143 100644 --- a/lib/synapse/file_output.rb +++ b/lib/synapse/file_output.rb @@ -40,6 +40,9 @@ def write_backends_to_file(service_name, new_backends) end if old_backends == new_backends + # Prevent modifying the file unless something has actually changed + # This way clients can set watches on this file and update their + # internal state only when the smartstack state has actually changed return false else # Atomically write new sevice configuration file diff --git a/lib/synapse/haproxy.rb b/lib/synapse/haproxy.rb index 5344a576..89c50077 100644 --- a/lib/synapse/haproxy.rb +++ b/lib/synapse/haproxy.rb @@ -715,7 +715,8 @@ def generate_backend_stanza(watcher, config) stanza = [ "\nbackend #{watcher.name}", config.map {|c| "\t#{c}"}, - backends.map {|backend_name, backend| + backends.keys.shuffle.map {|backend_name| + backend = backends[backend_name] b = "\tserver #{backend_name} #{backend['host']}:#{backend['port']}" b = "#{b} cookie #{backend_name}" unless config.include?('mode tcp') b = "#{b} #{watcher.haproxy['server_options']}"