Add max_connect_errors configuration option.
This change adds the config option max_connect_errors for MySQL to this charm and sets a default of 100. Commit also includes the inclusion of this (default) config setting in the unit tests. Closes-Bug: #1776908 Change-Id: I33b9e29bd64ad8a1fec0edc3dfd657a87648b537
This commit is contained in:
parent
fc9b9dbcb9
commit
75fcf19f33
10
config.yaml
10
config.yaml
|
@ -365,3 +365,13 @@ options:
|
|||
This configuration option represents the warning and critical percentages
|
||||
that are used to check the number of threads connected to MySQL.
|
||||
The value should be written as a string containing two numbers separated by commas.
|
||||
max-connect-errors:
|
||||
type: int
|
||||
default: 100
|
||||
description: |
|
||||
This setting limits the number of successive unsuccessful connection
|
||||
requests that a host can make to MySQL. After max-connect-errors
|
||||
successive connection requests from a host are interrupted without a
|
||||
successful connection, the MySQL server blocks that host from making
|
||||
further connections.
|
||||
This setting is only for Ubuntu Xenial and newer releases.
|
||||
|
|
|
@ -273,6 +273,7 @@ def render_config(hosts=None):
|
|||
'binlogs_max_size': config('binlogs-max-size'),
|
||||
'binlogs_expire_days': config('binlogs-expire-days'),
|
||||
'performance_schema': config('performance-schema'),
|
||||
'max_connect_errors': config('max-connect-errors'),
|
||||
'is_leader': is_leader(),
|
||||
'server_id': get_server_id(),
|
||||
'series_upgrade': is_unit_upgrading_set(),
|
||||
|
|
|
@ -44,6 +44,10 @@ myisam-recover = {{ myisam_recover }}
|
|||
max_connections = {{ max_connections }}
|
||||
{% endif %}
|
||||
|
||||
{% if max_connect_errors %}
|
||||
max_connect_errors = {{ max_connect_errors }}
|
||||
{% endif %}
|
||||
|
||||
{% if wait_timeout != -1 -%}
|
||||
# Seconds before clearing idle connections
|
||||
wait_timeout = {{ wait_timeout }}
|
||||
|
|
|
@ -929,6 +929,7 @@ class TestConfigs(CharmTestCase):
|
|||
'binlogs_path': self.default_config['binlogs-path'],
|
||||
'cluster_name': 'juju_cluster',
|
||||
'binlogs_expire_days': self.default_config['binlogs-expire-days'],
|
||||
'max_connect_errors': self.default_config['max-connect-errors'],
|
||||
'ipv6': False,
|
||||
'innodb_file_per_table':
|
||||
self.default_config['innodb-file-per-table'],
|
||||
|
@ -987,6 +988,7 @@ class TestConfigs(CharmTestCase):
|
|||
'binlogs_path': self.default_config['binlogs-path'],
|
||||
'binlogs_expire_days': self.default_config['binlogs-expire-days'],
|
||||
'performance_schema': self.default_config['performance-schema'],
|
||||
'max_connect_errors': self.default_config['max-connect-errors'],
|
||||
'key_buffer': '32M',
|
||||
'default_storage_engine': 'InnoDB',
|
||||
'wsrep_log_conflicts': True,
|
||||
|
@ -1052,6 +1054,7 @@ class TestConfigs(CharmTestCase):
|
|||
'binlogs_path': self.default_config['binlogs-path'],
|
||||
'binlogs_expire_days': self.default_config['binlogs-expire-days'],
|
||||
'performance_schema': self.default_config['performance-schema'],
|
||||
'max_connect_errors': self.default_config['max-connect-errors'],
|
||||
'key_buffer': '32M',
|
||||
'default_storage_engine': 'InnoDB',
|
||||
'wsrep_log_conflicts': True,
|
||||
|
@ -1130,6 +1133,7 @@ class TestConfigs(CharmTestCase):
|
|||
'binlogs_path': self.default_config['binlogs-path'],
|
||||
'binlogs_expire_days': self.default_config['binlogs-expire-days'],
|
||||
'performance_schema': self.default_config['performance-schema'],
|
||||
'max_connect_errors': self.default_config['max-connect-errors'],
|
||||
'key_buffer': '32M',
|
||||
'default_storage_engine': 'InnoDB',
|
||||
'wsrep_log_conflicts': True,
|
||||
|
@ -1145,6 +1149,68 @@ class TestConfigs(CharmTestCase):
|
|||
context,
|
||||
perms=0o444)
|
||||
|
||||
@mock.patch.object(hooks, 'is_unit_upgrading_set')
|
||||
@mock.patch.object(os, 'makedirs')
|
||||
@mock.patch.object(hooks, 'get_cluster_host_ip')
|
||||
@mock.patch.object(hooks, 'get_wsrep_provider_options')
|
||||
@mock.patch.object(PerconaClusterHelper, 'parse_config')
|
||||
@mock.patch.object(hooks, 'render')
|
||||
@mock.patch.object(hooks, 'sst_password')
|
||||
@mock.patch.object(hooks, 'lsb_release')
|
||||
def test_render_config_max_connect_errors(
|
||||
self,
|
||||
lsb_release,
|
||||
sst_password,
|
||||
render,
|
||||
parse_config,
|
||||
get_wsrep_provider_options,
|
||||
get_cluster_host_ip,
|
||||
makedirs,
|
||||
mock_is_unit_upgrading_set):
|
||||
mock_is_unit_upgrading_set.return_value = False
|
||||
parse_config.return_value = {'key_buffer': '32M'}
|
||||
get_cluster_host_ip.return_value = '10.1.1.1'
|
||||
get_wsrep_provider_options.return_value = None
|
||||
sst_password.return_value = 'sstpassword'
|
||||
lsb_release.return_value = {'DISTRIB_CODENAME': 'bionic'}
|
||||
self.test_config.set('max-connect-errors', 42)
|
||||
|
||||
context = {
|
||||
'wsrep_slave_threads': 48,
|
||||
'server_id': hooks.get_server_id(),
|
||||
'server-id': hooks.get_server_id(),
|
||||
'is_leader': hooks.is_leader(),
|
||||
'series_upgrade': hooks.is_unit_upgrading_set(),
|
||||
'private_address': '10.1.1.1',
|
||||
'innodb_autoinc_lock_mode': '2',
|
||||
'cluster_hosts': '',
|
||||
'enable_binlogs': self.default_config['enable-binlogs'],
|
||||
'sst_password': 'sstpassword',
|
||||
'sst_method': self.default_config['sst-method'],
|
||||
'pxc_strict_mode': 'enforcing',
|
||||
'binlogs_max_size': self.default_config['binlogs-max-size'],
|
||||
'cluster_name': 'juju_cluster',
|
||||
'innodb_file_per_table':
|
||||
self.default_config['innodb-file-per-table'],
|
||||
'table_open_cache': self.default_config['table-open-cache'],
|
||||
'binlogs_path': self.default_config['binlogs-path'],
|
||||
'binlogs_expire_days': self.default_config['binlogs-expire-days'],
|
||||
'performance_schema': self.default_config['performance-schema'],
|
||||
'key_buffer': '32M',
|
||||
'default_storage_engine': 'InnoDB',
|
||||
'wsrep_log_conflicts': True,
|
||||
'ipv6': False,
|
||||
'wsrep_provider': '/usr/lib/galera3/libgalera_smm.so',
|
||||
'max_connect_errors': 42,
|
||||
}
|
||||
|
||||
hooks.render_config()
|
||||
hooks.render.assert_called_once_with(
|
||||
'mysqld.cnf',
|
||||
'/etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf',
|
||||
context,
|
||||
perms=0o444)
|
||||
|
||||
|
||||
class TestRenderConfigRestartOnChanged(CharmTestCase):
|
||||
TO_PATCH = [
|
||||
|
|
Loading…
Reference in New Issue