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

Modified:
  oslo_messaging/tests/functional/test_rabbitmq.py

NOTE(stephenfin): We must set the 'conn_pool_min_size' config option in
the 'RabbitMQFailoverTests.test_failover_scenario' test to avoid raising
an error because the minimum is greater than the configured value. This
wasn't necessary on stable/train due to the presence of change
I0f86416623a0b718516147f0660b4df2b74cf867 ("Setup backend scenarios for
functional tests") which changed how our functional tests ran.

Change-Id: I2ad4b9f1d012c9f0586a932ac27d96da1bcc4e4c
Closes-Bug: #1899533
(cherry picked from commit 00d15eaeab)
(cherry picked from commit 8f5847dcbe)
(cherry picked from commit 7c9b070f5b)
This commit is contained in:
Sean Mooney 2020-10-12 22:43:31 +01:00 committed by Stephen Finucane
parent 1613b7a968
commit 425ef28924
4 changed files with 23 additions and 1 deletions

View File

@ -25,7 +25,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,

View File

@ -1370,6 +1370,11 @@ 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:
text = 'rpc_conn_pool_size: {max_size} must be greater than' \
' or equal to conn_pool_min_size:' \
' {min_size}'.format(max_size=max_size, min_size=min_size)
raise RuntimeError(text)
ttl = conf.oslo_messaging_rabbit.conn_pool_ttl
connection_pool = pool.ConnectionPool(

View File

@ -31,6 +31,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 six.moves import mock
load_tests = testscenarios.load_tests_apply_scenarios
@ -141,6 +142,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 = [

View File

@ -50,6 +50,7 @@ class RabbitMQFailoverTests(test_utils.BaseTestCase):
# correctly
self.config(heartbeat_timeout_threshold=1,
rpc_conn_pool_size=1,
conn_pool_min_size=1,
kombu_reconnect_delay=0,
rabbit_retry_interval=0,
rabbit_retry_backoff=0,