diff --git a/src/config.yaml b/src/config.yaml index 66b77bc..625eefd 100644 --- a/src/config.yaml +++ b/src/config.yaml @@ -44,3 +44,11 @@ options: Time (in seconds) until the cache becomes invalid if not refreshed. Defaults to -1 (infinite). The value must be larger than auth_cache_refresh_interval else Router won't start. + max_connections: + type: int + default: 512 + description: | + Maximum number of connections to allow in direction to each MySQL + routing sessions, with one for the RW unit and another one for the RO + units of the MySQL innodb cluster. Defaults to 512. A valid range is + between 1 and 65535. diff --git a/src/lib/charm/openstack/mysql_router.py b/src/lib/charm/openstack/mysql_router.py index 72ee60c..71583b3 100644 --- a/src/lib/charm/openstack/mysql_router.py +++ b/src/lib/charm/openstack/mysql_router.py @@ -673,6 +673,7 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm): }, "DEFAULT": { "pid_file": self.mysqlrouter_pid_file, + "max_connections": str(self.options.max_connections), } } diff --git a/unit_tests/test_lib_charm_openstack_mysql_router.py b/unit_tests/test_lib_charm_openstack_mysql_router.py index 943969d..15e6b8c 100644 --- a/unit_tests/test_lib_charm_openstack_mysql_router.py +++ b/unit_tests/test_lib_charm_openstack_mysql_router.py @@ -695,6 +695,7 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): "ttl": '5', "auth_cache_ttl": '10', "auth_cache_refresh_interval": '7', + "max_connections": '1000', } def _fake_config(key=None): @@ -711,10 +712,13 @@ class TestMySQLRouterCharm(test_utils.PatchHelper): mrc.name = 'foobar' mrc.update_config_parameters = _mock_update_config_parameters + _metadata_config = _config_data.copy() + _metadata_config.pop('max_connections') _params = { - 'metadata_cache:jujuCluster': _config_data, + 'metadata_cache:jujuCluster': _metadata_config, 'DEFAULT': { 'client_ssl_mode': "PASSTHROUGH", + 'max_connections': _config_data['max_connections'], 'pid_file': '/run/mysql/mysqlrouter-foobar.pid' }, }