diff --git a/lib/synapse/config_generator/haproxy.rb b/lib/synapse/config_generator/haproxy.rb index 0d5df7c4..0d9cbcf5 100644 --- a/lib/synapse/config_generator/haproxy.rb +++ b/lib/synapse/config_generator/haproxy.rb @@ -1112,10 +1112,10 @@ def update_backends_at(socket_file_path, watchers) name, addr, state = re.match(line)[1..3] - next if ['FRONTEND', 'BACKEND'].include?(address) + next if ['FRONTEND', 'BACKEND'].include?(addr) cur_backends[name] ||= {} - cur_backends[name][address] = state + cur_backends[name][addr] = state end # build a list of backends that should be enabled diff --git a/spec/lib/synapse/haproxy_spec.rb b/spec/lib/synapse/haproxy_spec.rb index 8a37b9a2..89a965be 100644 --- a/spec/lib/synapse/haproxy_spec.rb +++ b/spec/lib/synapse/haproxy_spec.rb @@ -179,7 +179,7 @@ class MockWatcher; end; end it 'does not cause a restart due to the socket' do - mock_socket_output = "example_service,somehost:5555" + mock_socket_output = "example_service,somehost:5555,0,0,0,0,200,0,0,0,0,0,,0,0,0,0,DOWN,0," allow(subject).to receive(:talk_to_socket).with(socket_file_path, "show stat\n").and_return mock_socket_output expect(subject).to receive(:talk_to_socket).exactly(:once).with( @@ -192,9 +192,9 @@ class MockWatcher; end; end it 'disables existing servers on the socket' do - mock_socket_output = "example_service,somehost:5555\ndisabled_watcher,somehost:5555" + mock_socket_output = "example_service,somehost:5555,0,0,0,0,200,0,0,0,0,0,,0,0,0,0,DOWN,0,\ndisabled_watcher,somehost:5555,0,0,0,0,200,0,0,0,0,0,,0,0,0,0,UP,0," allow(subject).to receive(:talk_to_socket).with(socket_file_path, "show stat\n").and_return mock_socket_output - + stub_const('Synapse::ConfigGenerator::Haproxy::HAPROXY_CMD_BATCH_SIZE', 1) expect(subject).to receive(:talk_to_socket).exactly(:once).with( socket_file_path, "enable server example_service/somehost:5555\n"