From a8fe949612e6f06bb7b7a55b4b517ff8ad5149c1 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Tue, 12 Mar 2019 11:37:37 -0500 Subject: [PATCH] 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 --- mariadb/templates/bin/_start.py.tpl | 19 ++++++++++++++++++- mariadb/templates/statefulset.yaml | 1 + tools/deployment/keystone-auth/060-mariadb.sh | 1 - 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mariadb/templates/bin/_start.py.tpl b/mariadb/templates/bin/_start.py.tpl index 9c79fe9f4..884d1ae42 100644 --- a/mariadb/templates/bin/_start.py.tpl +++ b/mariadb/templates/bin/_start.py.tpl @@ -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) diff --git a/mariadb/templates/statefulset.yaml b/mariadb/templates/statefulset.yaml index 677b19e66..75bfc2a6a 100644 --- a/mariadb/templates/statefulset.yaml +++ b/mariadb/templates/statefulset.yaml @@ -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: diff --git a/tools/deployment/keystone-auth/060-mariadb.sh b/tools/deployment/keystone-auth/060-mariadb.sh index 6213fe72c..f3af71588 100755 --- a/tools/deployment/keystone-auth/060-mariadb.sh +++ b/tools/deployment/keystone-auth/060-mariadb.sh @@ -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}