Set [DEFAULT].unknown_config_option to warning.
This change sets the configuration option [DEFAULT].unknown_config_option to warning on upgrade-charm and on config-changed, this allows clusters running mysql-8.0.29 with the "name" key set to run. This option is set to "warning" by default, although mysqlrouter set it to "error". More details at https://dev.mysql.com/doc/mysql-router/8.0/en/mysql-router-conf-options.html#option_mysqlrouter_unknown_config_option Closes-Bug: #1971565 Change-Id: I9613706f1e2b573af10562fb6fbf0b9a7aedf6da
This commit is contained in:
parent
5a2da18002
commit
9563b204ad
|
@ -331,13 +331,24 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
|||
|
||||
def upgrade_charm(self):
|
||||
"""Custom upgrade charm function to handle special upgrade logic."""
|
||||
config = configparser.ConfigParser()
|
||||
config.read(self.mysqlrouter_conf)
|
||||
|
||||
# On upgrade set the unknown_config_option to warning (LP: #1971565)
|
||||
if 'unknown_config_option' not in config[DEFAULT_SECTION]:
|
||||
ch_core.hookenv.log(f'[{DEFAULT_SECTION}].unknown_config_option '
|
||||
f'is not present in the configuration file, '
|
||||
f'so setting it to "warning"')
|
||||
config[DEFAULT_SECTION]['unknown_config_option'] = 'warning'
|
||||
ch_core.hookenv.log("Writing {}".format(self.mysqlrouter_conf))
|
||||
with open(self.mysqlrouter_conf, 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
# Bug 1927981 - For mysql-innodb-clusters which were deployed with a
|
||||
# cluster name which was not 'jujuCluster', an extra section to the
|
||||
# mysqrouter.conf file was written which causes the mysql router
|
||||
# service to fail to start. Remove the extraneous section at charm
|
||||
# upgrade time.
|
||||
config = configparser.ConfigParser()
|
||||
config.read(self.mysqlrouter_conf)
|
||||
sections = list(filter(lambda x: x.startswith('metadata_cache'),
|
||||
config.sections()))
|
||||
if len(sections) > 1 and 'metadata_cache:jujuCluster' in sections:
|
||||
|
@ -740,6 +751,7 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -775,7 +775,8 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
mysql_router.DEFAULT_SECTION: {
|
||||
'client_ssl_mode': "PASSTHROUGH",
|
||||
'max_connections': _config_data['max_connections'],
|
||||
'pid_file': '/run/mysql/mysqlrouter-foobar.pid'
|
||||
'pid_file': '/run/mysql/mysqlrouter-foobar.pid',
|
||||
'unknown_config_option': 'warning',
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -837,3 +838,30 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
|||
mrc.upgrade_charm()
|
||||
self.assertIn('metadata_cache:foo', fake_config)
|
||||
self.assertNotIn('metadata_cache:.jujuCluster', fake_config)
|
||||
|
||||
def test_upgrade_charm_lp1971565(self):
|
||||
# test fix for Bug LP#1971565
|
||||
current_config = {
|
||||
"DEFAULT": {"client_ssl_mode": "NONE"},
|
||||
"metadata_cache:foo": {
|
||||
"ttl": '5',
|
||||
"auth_cache_ttl": '-1',
|
||||
"auth_cache_refresh_interval": '2',
|
||||
},
|
||||
"metadata_cache:jujuCluster": {
|
||||
"ttl": '5',
|
||||
},
|
||||
}
|
||||
fake_config = FakeConfigParser(current_config)
|
||||
|
||||
self.patch_object(mysql_router.charms_openstack.charm.OpenStackCharm,
|
||||
'upgrade_charm')
|
||||
self.patch_object(mysql_router.configparser, "ConfigParser",
|
||||
return_value=fake_config)
|
||||
|
||||
mrc = mysql_router.MySQLRouterCharm()
|
||||
mrc.upgrade_charm()
|
||||
self.assertIn('metadata_cache:foo', fake_config)
|
||||
self.assertIn('unknown_config_option', fake_config['DEFAULT'])
|
||||
self.assertEqual(fake_config['DEFAULT']['unknown_config_option'],
|
||||
'warning')
|
||||
|
|
Loading…
Reference in New Issue