From 0d2541459e63e377acbdc946d7b95b16f3ed8dce Mon Sep 17 00:00:00 2001 From: Jiri Kozel Date: Wed, 20 Dec 2023 11:57:07 +0100 Subject: [PATCH] Add more logs --- src/assert_db.py | 2 +- src/layman/__init__.py | 4 +++- src/setup_geoserver.py | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/assert_db.py b/src/assert_db.py index b6a694b43..26452ca9e 100644 --- a/src/assert_db.py +++ b/src/assert_db.py @@ -4,7 +4,7 @@ ATTEMPT_INTERVAL = 1 -MAX_ATTEMPTS = 10 +MAX_ATTEMPTS = 20 def main(): diff --git a/src/layman/__init__.py b/src/layman/__init__.py index 9ceef916b..5b2f72ebe 100644 --- a/src/layman/__init__.py +++ b/src/layman/__init__.py @@ -83,12 +83,14 @@ pipe.execute() with app.app_context(): - logger.info(f'Adjusting GeoServer roles') if settings.GEOSERVER_ADMIN_AUTH: + logger.info(f'Ensuring Layman user on GeoServer') gs_util.ensure_user(settings.LAYMAN_GS_USER, settings.LAYMAN_GS_PASSWORD, settings.GEOSERVER_ADMIN_AUTH) + logger.info(f'Adjusting GeoServer proxy base URL') gs_util.ensure_proxy_base_url(settings.LAYMAN_GS_PROXY_BASE_URL_WITH_PLACEHOLDERS, settings.LAYMAN_GS_AUTH) + logger.info(f'After adjusting GeoServer proxy base URL') if not IN_UPGRADE_PROCESS: logger.info(f'Adjusting GeoServer SRS') diff --git a/src/setup_geoserver.py b/src/setup_geoserver.py index 7b648f865..aaf23a18e 100644 --- a/src/setup_geoserver.py +++ b/src/setup_geoserver.py @@ -42,6 +42,16 @@ def ensure_jdbc_role_service_internal_schema(): logger.info(f" Waiting for DB") wait_for_db(db_conn) + tables_and_views_query = """ +select table_schema, table_type, table_name + from INFORMATION_SCHEMA.tables + where table_schema in ('_role_service', '_prime_schema') +order by table_schema, table_type, table_name + """ + tables_and_views = db_util.run_query(tables_and_views_query, uri_str=uri_str) + logger.info(f" Current tables and views: {tables_and_views}") + + logger.info(f" Checking internal role service DB schema") schema_query = f'''SELECT COUNT(*) FROM information_schema.schemata WHERE schema_name = %s;''' schema_exists = db_util.run_query(schema_query, (internal_service_schema, ), uri_str=uri_str)[0][0] @@ -64,6 +74,9 @@ def ensure_jdbc_role_service_internal_schema(): else: prime_schema_exists = db_util.run_query(schema_query, (settings.LAYMAN_PRIME_SCHEMA, ), uri_str=uri_str)[0][0] if prime_schema_exists: + tables_and_views = db_util.run_query(tables_and_views_query, uri_str=uri_str) + logger.info(f" Current tables and views 2: {tables_and_views}") + logger.info(f' Recreate Role Service admin role views') create_admin_roles_view = f"""CREATE OR REPLACE view {internal_service_schema}.admin_roles as @@ -75,6 +88,10 @@ def ensure_jdbc_role_service_internal_schema(): ;""" db_util.run_statement(create_admin_roles_view, (settings.LAYMAN_GS_ROLE,), uri_str=uri_str) + tables_and_views = db_util.run_query(tables_and_views_query, uri_str=uri_str) + logger.info(f" Current tables and views 3: {tables_and_views}") + + create_admin_user_roles_view = f"""CREATE OR REPLACE view {internal_service_schema}.admin_user_roles as select %s as username, %s as rolename @@ -91,6 +108,10 @@ def ensure_jdbc_role_service_internal_schema(): db_util.run_statement(create_admin_user_roles_view, ( settings.LAYMAN_GS_USER, settings.LAYMAN_GS_ROLE, settings.LAYMAN_GS_USER, settings.GEOSERVER_ADMIN_USER, settings.LAYMAN_GS_ROLE,), uri_str=uri_str) + logger.info(f' Recreate Role Service admin role views DONE') + + tables_and_views = db_util.run_query(tables_and_views_query, uri_str=uri_str) + logger.info(f" Current tables and views 4: {tables_and_views}") def main():