Mariadb: Support changing the root password

This PS udpates the mariadb chart to support changing the root password.

Additionally it moves to use three replicas in the gate

Change-Id: I286ad0b892e5ea2f85636a0c7af58598bcfdaec4
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2019-03-12 11:37:37 -05:00 committed by Steve Wilkerson
parent 0b44116506
commit a8fe949612
3 changed files with 19 additions and 2 deletions

View File

@ -246,7 +246,8 @@ def mysqld_bootstrap():
"GRANT ALL ON *.* TO '{0}'@'%' WITH GRANT OPTION ;\n"
"DROP DATABASE IF EXISTS test ;\n"
"FLUSH PRIVILEGES ;\n"
"SHUTDOWN ;".format(mysql_dbadmin_username, mysql_dbadmin_password))
"SHUTDOWN ;".format(mysql_dbadmin_username,
mysql_dbadmin_password))
bootstrap_sql_file = tempfile.NamedTemporaryFile(suffix='.sql').name
with open(bootstrap_sql_file, 'w') as f:
f.write(template)
@ -680,6 +681,22 @@ def run_mysqld(cluster='existing'):
'--defaults-file=/etc/mysql/admin_user.cnf'
], logger)
logger.info("Setting the root password to the current value")
template = ("CREATE OR REPLACE USER '{0}'@'%' IDENTIFIED BY \'{1}\' ;\n"
"GRANT ALL ON *.* TO '{0}'@'%' WITH GRANT OPTION ;\n"
"FLUSH PRIVILEGES ;\n"
"SHUTDOWN ;".format(mysql_dbadmin_username,
mysql_dbadmin_password))
bootstrap_sql_file = tempfile.NamedTemporaryFile(suffix='.sql').name
with open(bootstrap_sql_file, 'w') as f:
f.write(template)
f.close()
run_cmd_with_logging([
'mysqld', '--bind-address=127.0.0.1',
"--init-file={0}".format(bootstrap_sql_file)
], logger)
os.remove(bootstrap_sql_file)
run_cmd_with_logging(mysqld_cmd, logger)

View File

@ -73,6 +73,7 @@ metadata:
{{ tuple $envAll | include "helm-toolkit.snippets.release_uuid" }}
configmap-bin-hash: {{ tuple "configmap-bin.yaml" . | include "helm-toolkit.utils.hash" }}
configmap-etc-hash: {{ tuple "configmap-etc.yaml" . | include "helm-toolkit.utils.hash" }}
mariadb-dbadmin-password-hash: {{ tuple "secret-dbadmin-password.yaml" . | include "helm-toolkit.utils.hash" }}
labels:
{{ tuple $envAll "mariadb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }}
spec:

View File

@ -23,7 +23,6 @@ make mariadb
: ${OSH_INFRA_EXTRA_HELM_ARGS:=""}
helm upgrade --install mariadb ./mariadb \
--namespace=openstack \
--set pod.replicas.server=1 \
${OSH_INFRA_EXTRA_HELM_ARGS} \
${OSH_INFRA_EXTRA_HELM_ARGS_MARIADB}