[mysql] Use constant for mysqld binary name

Change-Id: I996141242dac9978283e5d2086579c75d120ed8b
This commit is contained in:
Vasyl Saienko 2024-11-11 08:59:55 +00:00
parent f706586123
commit 4ee7ebda43
3 changed files with 10 additions and 6 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v10.6.7
description: OpenStack-Helm MariaDB
name: mariadb
version: 0.2.52
version: 0.2.53
home: https://mariadb.com/kb/en/
icon: http://badges.mariadb.org/mariadb-badge-180x60.png
sources:

View File

@ -119,6 +119,9 @@ cluster_leader_ttl = int(os.environ['CLUSTER_LEADER_TTL'])
state_configmap_update_period = 10
default_sleep = 20
# set one name for all commands, avoid "magic names"
MYSQL_BINARY_NAME='mysqld'
def ensure_state_configmap(pod_namespace, configmap_name, configmap_body):
"""Ensure the state configmap exists.
@ -179,7 +182,7 @@ def stop_mysqld():
def is_pid_mysqld(pid):
with open('/proc/{0}/comm'.format(pid), "r") as mysqld_pidfile:
comm = mysqld_pidfile.readlines()[0].rstrip('\n')
if comm.startswith('mysqld'):
if comm.startswith(MYSQL_BINARY_NAME):
return True
else:
return False
@ -306,7 +309,7 @@ def mysqld_bootstrap():
f.write(template)
f.close()
run_cmd_with_logging([
'mysqld', '--user=mysql', '--bind-address=127.0.0.1',
MYSQL_BINARY_NAME, '--user=mysql', '--bind-address=127.0.0.1',
'--wsrep_cluster_address=gcomm://',
"--init-file={0}".format(bootstrap_sql_file)
], logger)
@ -577,7 +580,7 @@ def update_grastate_on_restart():
"""Extract recovered wsrep position from uncleanly exited node."""
wsrep_recover = subprocess.Popen( # nosec
[
'mysqld', '--bind-address=127.0.0.1',
MYSQL_BINARY_NAME, '--bind-address=127.0.0.1',
'--wsrep_cluster_address=gcomm://', '--wsrep-recover'
],
stdout=subprocess.PIPE,
@ -808,7 +811,7 @@ def run_mysqld(cluster='existing'):
mysqld_write_cluster_conf(mode='run')
launch_leader_election()
launch_cluster_monitor()
mysqld_cmd = ['mysqld', '--user=mysql']
mysqld_cmd = [MYSQL_BINARY_NAME, '--user=mysql']
if cluster == 'new':
mysqld_cmd.append('--wsrep-new-cluster')
@ -844,7 +847,7 @@ def run_mysqld(cluster='existing'):
f.write(template)
f.close()
run_cmd_with_logging([
'mysqld', '--bind-address=127.0.0.1', '--wsrep-on=false',
MYSQL_BINARY_NAME, '--bind-address=127.0.0.1', '--wsrep-on=false',
"--init-file={0}".format(bootstrap_sql_file)
], logger)
os.remove(bootstrap_sql_file)

View File

@ -68,4 +68,5 @@ mariadb:
- 0.2.50 Add cluster-wait job
- 0.2.51 Add 2024.2 overrides
- 0.2.52 Added SSL support to cluster-wait job
- 0.2.53 Use constant for mysql binary name
...