rabbit: shuffle hosts before building kombu URL
This restores behavior as it was back in the Juno cycle. This was
changed in a refactor during the Kilo cycle (973301aa
) when the kombu
failover_strategy was set to shuffle. But the failover_strategy only
affects failovers; it does not influence which host receives the
initial connection.
Thus, if multiple hosts are given, the first host will receive all of
the initial connections. By shuffling the hosts before building the
URL given to kombu, rudimentary load balancing is achieved and
connections are more evenly spread across broker nodes.
Change-Id: Ieecaf5f286f49302db29df9854359ef5d36b7a89
This commit is contained in:
parent
3a5db723aa
commit
f2beb5eaf1
@ -16,6 +16,7 @@ import collections
|
||||
import contextlib
|
||||
import functools
|
||||
import os
|
||||
import random
|
||||
import socket
|
||||
import ssl
|
||||
import threading
|
||||
@ -406,6 +407,7 @@ class Connection(object):
|
||||
LOG.warn(_LW('Selecting the kombu transport through the '
|
||||
'transport url (%s) is a experimental feature '
|
||||
'and this is not yet supported.') % url.transport)
|
||||
random.shuffle(url.hosts)
|
||||
for host in url.hosts:
|
||||
transport = url.transport.replace('kombu+', '')
|
||||
transport = transport.replace('rabbit', 'amqp')
|
||||
@ -423,6 +425,7 @@ class Connection(object):
|
||||
transport = url.transport.replace('kombu+', '')
|
||||
self._url = "%s://%s" % (transport, virtual_host)
|
||||
else:
|
||||
random.shuffle(self.rabbit_hosts)
|
||||
for adr in self.rabbit_hosts:
|
||||
hostname, port = netutils.parse_host_port(
|
||||
adr, default_port=self.rabbit_port)
|
||||
|
Loading…
Reference in New Issue
Block a user