Skip to content

Commit

Permalink
Add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 20, 2023
1 parent 8875c87 commit 0d25414
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/assert_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


ATTEMPT_INTERVAL = 1
MAX_ATTEMPTS = 10
MAX_ATTEMPTS = 20


def main():
Expand Down
4 changes: 3 additions & 1 deletion src/layman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
21 changes: 21 additions & 0 deletions src/setup_geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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():
Expand Down

0 comments on commit 0d25414

Please sign in to comment.