Fix boostrap pxc on systemd
Percona-cluster was quietly failing to bootstrap. The problem was brought to light but not caused by a recent commit which added a service stop of mysql before the bootstrap. Systemd systems try to run: systemctl bootstrap-pxc mysql Which returns: Unknown operation bootstrap-pxc. This fix both handles systemd bootstrapping and is more verbose when a bootstrap fails. Change-Id: Ifdaa3114fd2de315d2da8d2bd6a807e503d26dce Partial-Bug: 1600001
This commit is contained in:
parent
bf8983a7cd
commit
dd9f4e7b71
|
@ -27,7 +27,6 @@ from charmhelpers.core.hookenv import (
|
|||
network_get_primary_address,
|
||||
)
|
||||
from charmhelpers.core.host import (
|
||||
service,
|
||||
service_restart,
|
||||
service_start,
|
||||
file_hash,
|
||||
|
@ -91,6 +90,7 @@ from percona_utils import (
|
|||
register_configs,
|
||||
resolve_cnf_file,
|
||||
create_binlogs_directory,
|
||||
bootstrap_pxc,
|
||||
)
|
||||
|
||||
|
||||
|
@ -176,8 +176,7 @@ def render_config_restart_on_changed(clustered, hosts, bootstrap=False):
|
|||
update_db_rels = False
|
||||
if file_hash(resolve_cnf_file()) != pre_hash or bootstrap:
|
||||
if bootstrap:
|
||||
service('stop', 'mysql')
|
||||
service('bootstrap-pxc', 'mysql')
|
||||
bootstrap_pxc()
|
||||
# NOTE(dosaboy): this will not actually do anything if no cluster
|
||||
# relation id exists yet.
|
||||
notify_bootstrapped()
|
||||
|
|
|
@ -9,7 +9,8 @@ import uuid
|
|||
|
||||
from charmhelpers.core.host import (
|
||||
lsb_release,
|
||||
mkdir
|
||||
mkdir,
|
||||
service,
|
||||
)
|
||||
from charmhelpers.core.hookenv import (
|
||||
charm_dir,
|
||||
|
@ -27,6 +28,7 @@ from charmhelpers.core.hookenv import (
|
|||
WARNING,
|
||||
ERROR,
|
||||
cached,
|
||||
status_set,
|
||||
)
|
||||
from charmhelpers.fetch import (
|
||||
apt_install,
|
||||
|
@ -350,6 +352,27 @@ def is_bootstrapped():
|
|||
return False
|
||||
|
||||
|
||||
def bootstrap_pxc():
|
||||
"""Bootstrap PXC
|
||||
On systemd systems systemctl bootstrap-pxc mysql does not work.
|
||||
Run service mysql bootstrap-pxc to bootstrap."""
|
||||
service('stop', 'mysql')
|
||||
bootstrapped = service('bootstrap-pxc', 'mysql')
|
||||
if not bootstrapped:
|
||||
try:
|
||||
cmd = ['service', 'mysql', 'bootstrap-pxc']
|
||||
subprocess.check_call(cmd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
msg = 'Bootstrap PXC failed'
|
||||
error_msg = '{}: {}'.format(msg, e)
|
||||
status_set('blocked', msg)
|
||||
log(error_msg, ERROR)
|
||||
raise Exception(error_msg)
|
||||
# To make systemd aware mysql is running after a bootstrap
|
||||
service('start', 'mysql')
|
||||
log("Bootstrap PXC Succeeded", DEBUG)
|
||||
|
||||
|
||||
def notify_bootstrapped(cluster_rid=None, cluster_uuid=None):
|
||||
if cluster_rid:
|
||||
rids = [cluster_rid]
|
||||
|
|
Loading…
Reference in New Issue