Merge "Add a kombu_reconnect_splay setting"

This commit is contained in:
Zuul 2025-01-25 20:57:23 +00:00 committed by Gerrit Code Review
commit fe149aefb7
2 changed files with 17 additions and 0 deletions

View File

@ -118,6 +118,11 @@ rabbit_opts = [
max=amqpdriver.ACK_REQUEUE_EVERY_SECONDS_MAX * 0.9,
help='How long to wait (in seconds) before reconnecting in '
'response to an AMQP consumer cancel notification.'),
cfg.FloatOpt('kombu_reconnect_splay',
default=0.0,
min=0.0,
help='Random time to wait for when reconnecting in response '
'to an AMQP consumer cancel notification.'),
cfg.StrOpt('kombu_compression',
help="EXPERIMENTAL: Possible values are: gzip, bz2. If not "
"set compression will not be used. This option may not "
@ -750,6 +755,7 @@ class Connection:
driver_conf.heartbeat_timeout_threshold
self.heartbeat_rate = driver_conf.heartbeat_rate
self.kombu_reconnect_delay = driver_conf.kombu_reconnect_delay
self.kombu_reconnect_splay = driver_conf.kombu_reconnect_splay
self.amqp_durable_queues = driver_conf.amqp_durable_queues
self.amqp_auto_delete = driver_conf.amqp_auto_delete
self.ssl = driver_conf.ssl
@ -1094,6 +1100,10 @@ class Connection:
interval = (self.kombu_reconnect_delay + interval
if self.kombu_reconnect_delay > 0
else interval)
if self.kombu_reconnect_splay > 0:
interval += random.uniform(
0,
self.kombu_reconnect_splay) # nosec
info = {'err_str': exc, 'sleep_time': interval}
info.update(self._get_connection_info(conn_error=True))

View File

@ -0,0 +1,7 @@
---
features:
- |
Add a new option named `kombu_reconnect_splay` under
`oslo_messaging_rabbit` that could be used to add an extra random delay
before any reconnection when a recoverable error occur.
This delay is set to 0 by default so the original behavior is not changed.