Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add try/expect to avoid failure in startup #99

Merged
merged 3 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ jobs:
needs: [tests]
if: github.event_name == 'workflow_dispatch'
steps:
- name: Log Disk Usage Before Deploy Test
run: df -h

- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -174,6 +177,13 @@ jobs:
DB_URL: ${{ steps.pulumi.outputs.database_url_alembic }}
run: alembic upgrade head

- name: Log Disk Usage After Deploy Test
run: df -h
- name: List Docker Images
run: docker images
- name: Docker System Info
run: docker system df -v

deploy-staging:
name: Deploy [STAGING]
needs: [tests]
Expand Down
33 changes: 19 additions & 14 deletions cerulean_cloud/cloud_run_tipg/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

"""
import logging
import warnings
from typing import Any, List, Optional

import jinja2
Expand Down Expand Up @@ -109,20 +110,24 @@ class Config:
@app.on_event("startup")
async def startup_event() -> None:
"""Connect to database on startup."""
await connect_to_db(app, settings=postgres_settings)
assert getattr(app.state, "pool", None)

await register_collection_catalog(
app,
schemas=db_settings.schemas,
exclude_table_schemas=db_settings.exclude_table_schemas,
tables=db_settings.tables,
exclude_tables=db_settings.exclude_tables,
exclude_function_schemas=db_settings.exclude_function_schemas,
functions=db_settings.functions,
exclude_functions=db_settings.exclude_functions,
spatial=False, # False means allow non-spatial tables
)
try:
await connect_to_db(app, settings=postgres_settings)
assert getattr(app.state, "pool", None)

await register_collection_catalog(
app,
schemas=db_settings.schemas,
exclude_table_schemas=db_settings.exclude_table_schemas,
tables=db_settings.tables,
exclude_tables=db_settings.exclude_tables,
exclude_function_schemas=db_settings.exclude_function_schemas,
functions=db_settings.functions,
exclude_functions=db_settings.exclude_functions,
spatial=False, # False means allow non-spatial tables
)
except: # noqa
warnings.warn("Could not initiate TiPg", UserWarning)
pass


@app.on_event("shutdown")
Expand Down
2 changes: 1 addition & 1 deletion stack/sns_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"FUNCTION_URL": cloud_function_scene_relevancy.fxn.https_trigger_url
},
),
layers=["arn:aws:lambda:eu-central-1:770693421928:layer:Klayers-p38-requests:4"],
layers=["arn:aws:lambda:eu-central-1:770693421928:layer:Klayers-p38-requests:15"],
)
# Give SNS permissions to invoke the Lambda
lambda_permission = aws.lambda_.Permission(
Expand Down
Loading