Merge "Add max_total_connections configuration option"
This commit is contained in:
commit
a49fc1e693
@ -46,9 +46,13 @@ options:
|
||||
auth_cache_refresh_interval else Router won't start.
|
||||
max_connections:
|
||||
type: int
|
||||
default: 512
|
||||
default: 1024
|
||||
description: |
|
||||
Maximum number of connections to allow in direction to each MySQL
|
||||
If mysql router version < 8.0.27, this option will be set as max_connections
|
||||
in the config. Else will be max_total_connections.
|
||||
The max_connections is 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.
|
||||
units of the MySQL innodb cluster. A valid range is between 1 and 65535.
|
||||
The max_total_connections is the maximum number of client connections handled by Router, to help
|
||||
prevent running out of the file descriptors. A valid
|
||||
range is between 1 and 9223372036854775807.
|
||||
|
@ -755,7 +755,6 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
||||
},
|
||||
DEFAULT_SECTION: {
|
||||
"pid_file": self.mysqlrouter_pid_file,
|
||||
"max_connections": str(self.options.max_connections),
|
||||
"unknown_config_option": "warning", # LP: #1971565
|
||||
},
|
||||
LOGGING_SECTION: {
|
||||
@ -770,6 +769,15 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
||||
ch_core.hookenv.log("TLS mode PREFERRED", "DEBUG")
|
||||
_parameters["DEFAULT"]["client_ssl_mode"] = "PREFERRED"
|
||||
|
||||
if ch_core.host.cmp_pkgrevno('mysql-router', '8.0.27') >= 0:
|
||||
_parameters[DEFAULT_SECTION]["max_total_connections"] = str(
|
||||
self.options.max_connections
|
||||
)
|
||||
else:
|
||||
_parameters[DEFAULT_SECTION]["max_connections"] = str(
|
||||
self.options.max_connections
|
||||
)
|
||||
|
||||
with ch_core.host.restart_on_change(
|
||||
self.restart_map, restart_functions=self.restart_functions):
|
||||
ch_core.hookenv.log("Updating configuration parameters", "DEBUG")
|
||||
|
@ -776,7 +776,7 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
||||
mysql_router.METADATA_CACHE_SECTION: _metadata_config,
|
||||
mysql_router.DEFAULT_SECTION: {
|
||||
'client_ssl_mode': "PASSTHROUGH",
|
||||
'max_connections': _config_data['max_connections'],
|
||||
'max_total_connections': _config_data['max_connections'],
|
||||
'pid_file': '/run/mysql/mysqlrouter-foobar.pid',
|
||||
'unknown_config_option': 'warning',
|
||||
},
|
||||
@ -784,6 +784,9 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
||||
'level': 'INFO',
|
||||
},
|
||||
}
|
||||
# Successful > 8.0.27
|
||||
# Should use max_total_connections in config
|
||||
self.cmp_pkgrevno.return_value = 1
|
||||
|
||||
# Not bootstrapped yet
|
||||
self.exists.return_value = False
|
||||
@ -804,6 +807,15 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
||||
mrc.config_changed()
|
||||
_mock_update_config_parameters.assert_called_once_with(_params)
|
||||
|
||||
# Successful < 8.0.27
|
||||
# Should use max_connections in config
|
||||
self.cmp_pkgrevno.return_value = -1
|
||||
_params["DEFAULT"].pop("max_total_connections")
|
||||
_params["DEFAULT"]["max_connections"] = _config_data['max_connections']
|
||||
_mock_update_config_parameters.reset_mock()
|
||||
mrc.config_changed()
|
||||
_mock_update_config_parameters.assert_called_once_with(_params)
|
||||
|
||||
def test_custom_restart_function(self):
|
||||
self.patch_object(mysql_router.ch_core.host, "service_stop")
|
||||
self.patch_object(mysql_router.ch_core.host, "service_start")
|
||||
|
Loading…
Reference in New Issue
Block a user