From dcb30a5ebe2c1a03723d27d255379e37a839e2a0 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Wed, 10 Jul 2024 10:18:11 -0500 Subject: [PATCH] Align db scripts with sqlalchemy 2.0 Change-Id: Icb8085fabc6661226b0d8e3fdc7ed7d3afa478be --- keystone/Chart.yaml | 2 +- keystone/templates/bin/_cred-clean.py.tpl | 7 ++++- .../templates/bin/_endpoint-update.py.tpl | 30 ++++++++++++++----- releasenotes/notes/keystone.yaml | 1 + 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/keystone/Chart.yaml b/keystone/Chart.yaml index ae2dc6e412..3f84141467 100644 --- a/keystone/Chart.yaml +++ b/keystone/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Keystone name: keystone -version: 0.3.13 +version: 0.3.14 home: https://docs.openstack.org/keystone/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Keystone/OpenStack_Project_Keystone_vertical.png sources: diff --git a/keystone/templates/bin/_cred-clean.py.tpl b/keystone/templates/bin/_cred-clean.py.tpl index e01c3fc3b1..d95ed27377 100644 --- a/keystone/templates/bin/_cred-clean.py.tpl +++ b/keystone/templates/bin/_cred-clean.py.tpl @@ -128,7 +128,12 @@ except: try: cmd = "DELETE FROM credential" - user_engine.execute(cmd) + with user_engine.connect() as connection: + connection.execute(cmd) + try: + connection.commit() + except AttributeError: + pass logger.info('Deleted all entries in credential table') except: logger.critical('Failed to clean up credential table in keystone db') diff --git a/keystone/templates/bin/_endpoint-update.py.tpl b/keystone/templates/bin/_endpoint-update.py.tpl index 14f8fc3cf9..1433af21ae 100644 --- a/keystone/templates/bin/_endpoint-update.py.tpl +++ b/keystone/templates/bin/_endpoint-update.py.tpl @@ -73,7 +73,12 @@ try: "service_id = (select id from service where " "service.type = 'identity') and " "region_id = %s") - user_engine.execute(cmd, (endpoint_url,region_id)) + with user_engine.connect() as connection: + connection.execute(cmd, (endpoint_url,region_id)) + try: + connection.commit() + except AttributeError: + pass except: logger.critical("Could not update internal endpoint") raise @@ -86,7 +91,12 @@ try: "and service_id = (select id from service where " "service.type = 'identity') " "and region_id = %s") - user_engine.execute(cmd, (endpoint_url,region_id)) + with user_engine.connect() as connection: + connection.execute(cmd, (endpoint_url,region_id)) + try: + connection.commit() + except AttributeError: + pass except: logger.critical("Could not update admin endpoint") raise @@ -99,17 +109,23 @@ try: "and service_id = (select id from service where " "service.type = 'identity') " "and region_id = %s") - user_engine.execute(cmd, (endpoint_url,region_id)) + with user_engine.connect() as connection: + connection.execute(cmd, (endpoint_url,region_id)) + try: + connection.commit() + except AttributeError: + pass except: logger.critical("Could not update public endpoint") raise # Print endpoints try: - endpoints = user_engine.execute( - ("select interface, url from endpoint where service_id = " - "(select id from service where service.type = 'identity')") - ).fetchall() + with user_engine.connect() as connection: + endpoints = connection.execute( + ("select interface, url from endpoint where service_id = " + "(select id from service where service.type = 'identity')") + ).fetchall() for row in endpoints: logger.info("endpoint ({0}): {1}".format(row[0], row[1])) except: diff --git a/releasenotes/notes/keystone.yaml b/releasenotes/notes/keystone.yaml index 129abc0fbc..74a8ad126a 100644 --- a/releasenotes/notes/keystone.yaml +++ b/releasenotes/notes/keystone.yaml @@ -60,4 +60,5 @@ keystone: - 0.3.11 Fix custom annotations when helm3_hook is disabled - 0.3.12 Enable custom annotations for Openstack secrets - 0.3.13 Update images used by default + - 0.3.14 Align db scripts with sqlalchemy 2.0 ...