From 1775e1bea608b0600aacc83ec636746d79cc7727 Mon Sep 17 00:00:00 2001 From: Jose Bautista Date: Sat, 23 Apr 2022 17:11:19 +0300 Subject: [PATCH] Update create db user queries Using GRANT to create users was deprecated in 5.7. The current query to create user fails with new versions of mysql. Change-Id: If991778763dc0961508e8466244955fd71b47591 --- helm-toolkit/Chart.yaml | 2 +- helm-toolkit/templates/scripts/_db-init.py.tpl | 6 ++++-- releasenotes/notes/helm-toolkit.yaml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/helm-toolkit/Chart.yaml b/helm-toolkit/Chart.yaml index a8942ad5d..4b76d4871 100644 --- a/helm-toolkit/Chart.yaml +++ b/helm-toolkit/Chart.yaml @@ -15,7 +15,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Helm-Toolkit name: helm-toolkit -version: 0.2.52 +version: 0.2.53 home: https://docs.openstack.org/openstack-helm icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png sources: diff --git a/helm-toolkit/templates/scripts/_db-init.py.tpl b/helm-toolkit/templates/scripts/_db-init.py.tpl index 4294d40c5..6027b9515 100644 --- a/helm-toolkit/templates/scripts/_db-init.py.tpl +++ b/helm-toolkit/templates/scripts/_db-init.py.tpl @@ -133,8 +133,10 @@ except: # Create DB User try: root_engine.execute( - "GRANT ALL ON `{0}`.* TO \'{1}\'@\'%%\' IDENTIFIED BY \'{2}\' {3}".format( - database, user, password, mysql_x509)) + "CREATE USER IF NOT EXISTS \'{0}\'@\'%%\' IDENTIFIED BY \'{1}\' {2}".format( + user, password, mysql_x509)) + root_engine.execute( + "GRANT ALL ON `{0}`.* TO \'{1}\'@\'%%\'".format(database, user)) logger.info("Created user {0} for {1}".format(user, database)) except: logger.critical("Could not create user {0} for {1}".format(user, database)) diff --git a/releasenotes/notes/helm-toolkit.yaml b/releasenotes/notes/helm-toolkit.yaml index eb13d25ea..2c7c292a1 100644 --- a/releasenotes/notes/helm-toolkit.yaml +++ b/releasenotes/notes/helm-toolkit.yaml @@ -59,4 +59,5 @@ helm-toolkit: - 0.2.50 Allow tls for external ingress without specifying key and crt - 0.2.51 Added a random delay up to 300 seconds to remote backup upload/download for load spreading purpose - 0.2.52 Decreased random delay to up to 30 seconds and switched remote backup verification protocol to md5 + - 0.2.53 Update create db user queries ...