Add max_connections configuration option

Allow the user to change the number of connections to the database
cluster units to their needs.
The default value is the same as without the configuration option.

Closes-Bug: #1929826
Change-Id: I10556e9d373cd8505c4e2e96d2b6031fe4ee9166
This commit is contained in:
Olivier Dufour-Cuvillier 2021-11-26 12:11:23 +01:00
parent 6df44f9506
commit 01587ab402
3 changed files with 14 additions and 1 deletions

View File

@ -44,3 +44,11 @@ options:
Time (in seconds) until the cache becomes invalid if not refreshed. Time (in seconds) until the cache becomes invalid if not refreshed.
Defaults to -1 (infinite). The value must be larger than Defaults to -1 (infinite). The value must be larger than
auth_cache_refresh_interval else Router won't start. 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.

View File

@ -673,6 +673,7 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
}, },
"DEFAULT": { "DEFAULT": {
"pid_file": self.mysqlrouter_pid_file, "pid_file": self.mysqlrouter_pid_file,
"max_connections": str(self.options.max_connections),
} }
} }

View File

@ -695,6 +695,7 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
"ttl": '5', "ttl": '5',
"auth_cache_ttl": '10', "auth_cache_ttl": '10',
"auth_cache_refresh_interval": '7', "auth_cache_refresh_interval": '7',
"max_connections": '1000',
} }
def _fake_config(key=None): def _fake_config(key=None):
@ -711,10 +712,13 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
mrc.name = 'foobar' mrc.name = 'foobar'
mrc.update_config_parameters = _mock_update_config_parameters mrc.update_config_parameters = _mock_update_config_parameters
_metadata_config = _config_data.copy()
_metadata_config.pop('max_connections')
_params = { _params = {
'metadata_cache:jujuCluster': _config_data, 'metadata_cache:jujuCluster': _metadata_config,
'DEFAULT': { 'DEFAULT': {
'client_ssl_mode': "PASSTHROUGH", 'client_ssl_mode': "PASSTHROUGH",
'max_connections': _config_data['max_connections'],
'pid_file': '/run/mysql/mysqlrouter-foobar.pid' 'pid_file': '/run/mysql/mysqlrouter-foobar.pid'
}, },
} }