rabbit: validate input for retry options
Currently rabbit_retry_interval=0 is internally translated to rabbit_retry_interval=1, which may hide wrong expectation by operators. Add minimum boundary to make sure the given value is valid and is used actually. Also set the minimum boundary for backoff and max as well, to reject too small values or even negative value which may cause malfunction. Change-Id: Iaef2f3c52d6475742dd06c76dfeaebc1c7691d9a
This commit is contained in:
parent
f3aec8e756
commit
5c0b70beaa
@ -140,16 +140,18 @@ rabbit_opts = [
|
||||
default='AMQPLAIN',
|
||||
help='The RabbitMQ login method.'),
|
||||
cfg.IntOpt('rabbit_retry_interval',
|
||||
min=1,
|
||||
default=1,
|
||||
help='How frequently to retry connecting with RabbitMQ.'),
|
||||
cfg.IntOpt('rabbit_retry_backoff',
|
||||
default=2,
|
||||
min=0,
|
||||
help='How long to backoff for between retries when connecting '
|
||||
'to RabbitMQ.'),
|
||||
cfg.IntOpt('rabbit_interval_max',
|
||||
default=30,
|
||||
help='Maximum interval of RabbitMQ connection retries. '
|
||||
'Default is 30 seconds.'),
|
||||
min=1,
|
||||
help='Maximum interval of RabbitMQ connection retries.'),
|
||||
cfg.BoolOpt('rabbit_ha_queues',
|
||||
default=False,
|
||||
help='Try to use HA queues in RabbitMQ (x-ha-policy: all). '
|
||||
@ -1053,7 +1055,7 @@ class Connection:
|
||||
self.connection.ensure_connection(
|
||||
errback=on_error,
|
||||
max_retries=self.max_retries,
|
||||
interval_start=self.interval_start or 1,
|
||||
interval_start=self.interval_start,
|
||||
interval_step=self.interval_stepping,
|
||||
interval_max=self.interval_max,
|
||||
)
|
||||
@ -1156,7 +1158,7 @@ class Connection:
|
||||
execute_method, channel=self.channel,
|
||||
max_retries=retry,
|
||||
errback=on_error,
|
||||
interval_start=self.interval_start or 1,
|
||||
interval_start=self.interval_start,
|
||||
interval_step=self.interval_stepping,
|
||||
interval_max=self.interval_max,
|
||||
on_revive=on_reconnection)
|
||||
|
@ -1038,8 +1038,8 @@ class RpcKombuHATestCase(test_utils.BaseTestCase):
|
||||
super().setUp()
|
||||
transport_url = 'rabbit:/host1,host2,host3,host4,host5/'
|
||||
self.messaging_conf.transport_url = transport_url
|
||||
self.config(rabbit_retry_interval=0.01,
|
||||
rabbit_retry_backoff=0.01,
|
||||
self.config(rabbit_retry_interval=1.0,
|
||||
rabbit_retry_backoff=1.0,
|
||||
kombu_reconnect_delay=0,
|
||||
heartbeat_timeout_threshold=0,
|
||||
group="oslo_messaging_rabbit")
|
||||
|
Loading…
x
Reference in New Issue
Block a user