add min of 1 to rpc_conn_pool_size
This change add a min value of 1 to [oslo_messaging_rabbit]/rpc_conn_pool_size such that there is always at least 1 connection avaiable. This change add a runtime check to ensure that [oslo_messaging_rabbit]/rpc_conn_pool_size is greater than or equal too [oslo_messaging_rabbit]/conn_pool_min_size Change-Id: I2ad4b9f1d012c9f0586a932ac27d96da1bcc4e4c Closes-Bug: #1899533
This commit is contained in:
parent
a997f09e5b
commit
00d15eaeab
@ -24,7 +24,8 @@ from oslo_messaging import exceptions
|
||||
base_opts = [
|
||||
cfg.IntOpt('rpc_conn_pool_size', default=30,
|
||||
deprecated_group='DEFAULT',
|
||||
help='Size of RPC connection pool.'),
|
||||
help='Size of RPC connection pool.',
|
||||
min=1),
|
||||
cfg.IntOpt('conn_pool_min_size', default=2,
|
||||
help='The pool size limit for connections expiration policy'),
|
||||
cfg.IntOpt('conn_pool_ttl', default=1200,
|
||||
|
@ -1387,6 +1387,10 @@ class RabbitDriver(amqpdriver.AMQPDriverBase):
|
||||
# the pool configuration properties
|
||||
max_size = conf.oslo_messaging_rabbit.rpc_conn_pool_size
|
||||
min_size = conf.oslo_messaging_rabbit.conn_pool_min_size
|
||||
if max_size < min_size:
|
||||
raise RuntimeError(
|
||||
f"rpc_conn_pool_size: {max_size} must be greater than "
|
||||
f"or equal to conn_pool_min_size: {min_size}")
|
||||
ttl = conf.oslo_messaging_rabbit.conn_pool_ttl
|
||||
|
||||
connection_pool = pool.ConnectionPool(
|
||||
|
@ -33,6 +33,7 @@ from oslo_messaging._drivers import common as driver_common
|
||||
from oslo_messaging._drivers import impl_rabbit as rabbit_driver
|
||||
from oslo_messaging.exceptions import MessageDeliveryFailure
|
||||
from oslo_messaging.tests import utils as test_utils
|
||||
from oslo_messaging.transport import DriverLoadFailure
|
||||
from unittest import mock
|
||||
|
||||
load_tests = testscenarios.load_tests_apply_scenarios
|
||||
@ -143,6 +144,20 @@ class TestRabbitDriverLoad(test_utils.BaseTestCase):
|
||||
|
||||
self.assertIsInstance(driver, rabbit_driver.RabbitDriver)
|
||||
|
||||
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection'
|
||||
'.ensure_connection')
|
||||
@mock.patch('oslo_messaging._drivers.impl_rabbit.Connection.reset')
|
||||
def test_driver_load_max_less_than_min(self, fake_ensure, fake_reset):
|
||||
self.config(
|
||||
rpc_conn_pool_size=1, conn_pool_min_size=2,
|
||||
group='oslo_messaging_rabbit')
|
||||
self.messaging_conf.transport_url = self.transport_url
|
||||
error = self.assertRaises(
|
||||
DriverLoadFailure, oslo_messaging.get_transport, self.conf)
|
||||
self.assertIn(
|
||||
"rpc_conn_pool_size: 1 must be greater than or equal "
|
||||
"to conn_pool_min_size: 2", str(error))
|
||||
|
||||
|
||||
class TestRabbitDriverLoadSSL(test_utils.BaseTestCase):
|
||||
scenarios = [
|
||||
|
Loading…
Reference in New Issue
Block a user