Configure /run/mysql location for PID file
Ensure that a location in /run is used for the PID file for the mysqlrouter instance - this ensures that in the event of a power outage, the old PID file will not be present and the daemon will correctly startup when the machine starts up. Update systemd configuration to create /run/mysql and to use the mysql user and group to execute the daemon. Switch to 'forking' mode to ensure that the mysqlrouter process gets tracked by systemd. Closes-Bug: 1931095 Change-Id: Id3f7605ad1e9e4a6e4b0a1abe8000abd75b5b0fd
This commit is contained in:
parent
b2e1a41e9b
commit
72aca90ea3
|
@ -80,6 +80,17 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
||||||
# LP Bug #1915842
|
# LP Bug #1915842
|
||||||
_waiting_for_initial_communication_packet_error = 2013
|
_waiting_for_initial_communication_packet_error = 2013
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mysqlrouter_pid_file(self):
|
||||||
|
"""Determine the path for the mysqlrouter PID file.
|
||||||
|
|
||||||
|
:param self: Self
|
||||||
|
:type self: MySQLRouterCharm instance
|
||||||
|
:returns: Path to the PID file in /run
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
return "/run/mysql/mysqlrouter-{}.pid".format(self.name)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mysqlrouter_bin(self):
|
def mysqlrouter_bin(self):
|
||||||
"""Determine the path to the mysqlrouter binary.
|
"""Determine the path to the mysqlrouter binary.
|
||||||
|
@ -654,15 +665,18 @@ class MySQLRouterCharm(charms_openstack.charm.OpenStackCharm):
|
||||||
"auth_cache_ttl": str(self.options.auth_cache_ttl),
|
"auth_cache_ttl": str(self.options.auth_cache_ttl),
|
||||||
"auth_cache_refresh_interval":
|
"auth_cache_refresh_interval":
|
||||||
str(self.options.auth_cache_refresh_interval),
|
str(self.options.auth_cache_refresh_interval),
|
||||||
|
},
|
||||||
|
"DEFAULT": {
|
||||||
|
"pid_file": self.mysqlrouter_pid_file,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.ssl_ca:
|
if self.ssl_ca:
|
||||||
ch_core.hookenv.log("TLS mode PASSTHROUGH", "DEBUG")
|
ch_core.hookenv.log("TLS mode PASSTHROUGH", "DEBUG")
|
||||||
_parameters["DEFAULT"] = {"client_ssl_mode": "PASSTHROUGH"}
|
_parameters["DEFAULT"]["client_ssl_mode"] = "PASSTHROUGH"
|
||||||
else:
|
else:
|
||||||
ch_core.hookenv.log("TLS mode PREFERRED", "DEBUG")
|
ch_core.hookenv.log("TLS mode PREFERRED", "DEBUG")
|
||||||
_parameters["DEFAULT"] = {"client_ssl_mode": "PREFERRED"}
|
_parameters["DEFAULT"]["client_ssl_mode"] = "PREFERRED"
|
||||||
|
|
||||||
with ch_core.host.restart_on_change(
|
with ch_core.host.restart_on_change(
|
||||||
self.restart_map, restart_functions=self.restart_functions):
|
self.restart_map, restart_functions=self.restart_functions):
|
||||||
|
|
|
@ -5,7 +5,10 @@ Description=MySQL Router
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=exec
|
Type=forking
|
||||||
|
User=mysql
|
||||||
|
Group=mysql
|
||||||
|
RuntimeDirectory=mysql
|
||||||
ExecStart=/var/lib/mysql/{{ options.charm_instance.name }}/start.sh
|
ExecStart=/var/lib/mysql/{{ options.charm_instance.name }}/start.sh
|
||||||
ExecStop=/var/lib/mysql/{{ options.charm_instance.name }}/stop.sh
|
ExecStop=/var/lib/mysql/{{ options.charm_instance.name }}/stop.sh
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
|
@ -679,11 +679,15 @@ class TestMySQLRouterCharm(test_utils.PatchHelper):
|
||||||
|
|
||||||
_mock_update_config_parameters = mock.MagicMock()
|
_mock_update_config_parameters = mock.MagicMock()
|
||||||
mrc = mysql_router.MySQLRouterCharm()
|
mrc = mysql_router.MySQLRouterCharm()
|
||||||
|
mrc.name = 'foobar'
|
||||||
mrc.update_config_parameters = _mock_update_config_parameters
|
mrc.update_config_parameters = _mock_update_config_parameters
|
||||||
|
|
||||||
_params = {
|
_params = {
|
||||||
'metadata_cache:jujuCluster': _config_data,
|
'metadata_cache:jujuCluster': _config_data,
|
||||||
'DEFAULT': {'client_ssl_mode': "PASSTHROUGH"},
|
'DEFAULT': {
|
||||||
|
'client_ssl_mode': "PASSTHROUGH",
|
||||||
|
'pid_file': '/run/mysql/mysqlrouter-foobar.pid'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Not bootstrapped yet
|
# Not bootstrapped yet
|
||||||
|
|
Loading…
Reference in New Issue