fix: add pg8000 graceful shutdown on Cloud Run scale-down#1669
fix: add pg8000 graceful shutdown on Cloud Run scale-down#1669panish16 wants to merge 4 commits into
Conversation
09921be to
2b071bb
Compare
…email and strr-pay
2b071bb to
3780bf5
Compare
|
| @@ -1,4 +1,186 @@ | |||
| # This file is automatically @generated by Poetry 2.3.4 and should not be changed by hand. | |||
| # This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. | |||
There was a problem hiding this comment.
poetry version is mismatched. is that intended?
There was a problem hiding this comment.
Not intentional — the lockfile was regenerated with my local Poetry 2.3.2 when I added the cloud-sql-connector dependency. The 2.3.4 header was from the previous lockfile. The lock content (packages and hashes) is the same; only the generator version comment in line 1 differs. I can upgrade Poetry locally to 2.3.4 and regenerate if you'd prefer consistency.
| @@ -1,4 +1,186 @@ | |||
| # This file is automatically @generated by Poetry 2.3.4 and should not be changed by hand. | |||
| # This file is automatically @generated by Poetry 2.3.2 and should not be changed by hand. | |||
There was a problem hiding this comment.
same comment here as above about the poetry version
There was a problem hiding this comment.
Same as above — same unintentional regeneration with local Poetry 2.3.2. Content is correct.
| # Path to sources | ||
| #sonar.sources=strr-api/src/**/* | ||
| sonar.exclusions=strr-api/migrations/**/*,strr-api/devops/**/*,strr-api/tests/**/*,testing/**/* | ||
| sonar.exclusions=strr-api/migrations/**/*,strr-api/devops/**/*,strr-api/tests/**/*,testing/**/*,queue_services/**/tests/**/* |
There was a problem hiding this comment.
whats the reason for adding this?
There was a problem hiding this comment.
SonarCloud was picking up the new test files added under queue_services/ as source files and reporting 0% coverage on them (the main SonarCloud scan doesn't run the queue_services test suites separately). Without the exclusion, the quality gate would flag those test files as unmeasured source. This follows the same pattern as the existing testing/**/* exclusion already in the file.
|
hey @panish16 thanks for integrating the |
| assert stored.meta_data["email_type"] == "STRATA_HOTEL_REGISTRATION_ACTIVE" | ||
|
|
||
|
|
||
| def test_email_no_cloud_event_data(client, queue_envelope, simple_cloud_event): |
There was a problem hiding this comment.
what are these unit & integration tests added for in this project?
wasnt it already at 100% coverage?
There was a problem hiding this comment.
These tests cover the new setup_pg8000_close_event_listener(db.engine) call added to create_app() in __init__.py. Without them, the 3 new lines in that function would be uncovered, dropping coverage below 100% and failing the SonarCloud gate.
|
@jimmypalelil Good question! To clarify why the fix is scoped to just
|
Fixes version mismatch flagged in PR review — lockfiles were previously regenerated with local Poetry 2.3.2 instead of the expected newer version.
|



Summary
connectevent listener on app startup that wraps each pg8000 connection'sclose()to suppresspg8000.exceptions.InterfaceErrorduring Cloud Run scale-downpg8000.exceptions.InterfaceError: network errorlogged when Cloud Run terminates idle instances and SQLAlchemy's connection pool teardown tries to close already-severed socketsstrr-emailandstrr-payconnect via Unix socket (no Cloud SQL Connector dependency), so the listener is implemented inline using the same logicServices fixed
queue_services/strr-email/src/strr_email/__init__.pyqueue_services/strr-pay/src/strr_pay/__init__.pyTest plan
pg8000.exceptions.InterfaceErrorentries in GCP Log Explorer forbcrbk9-prodproject after deployment