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

feat: Report database errors when waiting for database in entrypoint #3823

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

matthewelwell
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Based on a debugging session with a customer, it would be useful to be able to see the actual error message that occurs when waitfordb fails. This PR adds the relevant information as a secondary log message.

How did you test this code?

❯ DATABASE_URL=postgres://invalid-role:[email protected]:5432/flagsmith LOG_LEVEL=WARNING python manage.py waitfordb --waitfor 1
core.management.commands.waitfordb WARNING  Database not yet ready for connections.
core.management.commands.waitfordb WARNING  Error was: OperationalError: connection to server at "127.0.0.1", port 5432 failed: FATAL:  role "invalid-role" does not exist

core.management.commands.waitfordb WARNING  Database not yet ready for connections.
core.management.commands.waitfordb WARNING  Error was: OperationalError: connection to server at "127.0.0.1", port 5432 failed: FATAL:  role "invalid-role" does not exist

core.management.commands.waitfordb WARNING  Database not yet ready for connections.
core.management.commands.waitfordb WARNING  Error was: OperationalError: connection to server at "127.0.0.1", port 5432 failed: FATAL:  role "invalid-role" does not exist

core.management.commands.waitfordb WARNING  Database not yet ready for connections.
core.management.commands.waitfordb WARNING  Error was: OperationalError: connection to server at "127.0.0.1", port 5432 failed: FATAL:  role "invalid-role" does not exist

core.management.commands.waitfordb ERROR    Failed to connect to DB within 1 seconds.
Failed to connect to DB within 1 seconds.

Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 22, 2024 4:06pm
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview Apr 22, 2024 4:06pm
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview Apr 22, 2024 4:06pm

@matthewelwell matthewelwell requested a review from khvn26 April 22, 2024 16:06
@github-actions github-actions bot added the api Issue related to the REST API label Apr 22, 2024
Copy link
Contributor

github-actions bot commented Apr 22, 2024

Uffizzi Preview deployment-50605 was deleted.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 95.93%. Comparing base (7451032) to head (4f8c0a3).
Report is 5 commits behind head on main.

Files Patch % Lines
api/core/management/commands/waitfordb.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3823      +/-   ##
==========================================
- Coverage   95.93%   95.93%   -0.01%     
==========================================
  Files        1103     1103              
  Lines       34842    34843       +1     
==========================================
  Hits        33427    33427              
- Misses       1415     1416       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@matthewelwell matthewelwell changed the title chore: add error information to log message on waitfordb command feat(logging): add error information to log message on waitfordb command Apr 22, 2024
@khvn26 khvn26 changed the title feat(logging): add error information to log message on waitfordb command feat: Report database errors when waiting for database in entrypoint Apr 22, 2024
@khvn26 khvn26 added this pull request to the merge queue Apr 22, 2024
Merged via the queue into main with commit a66c262 Apr 22, 2024
22 checks passed
@khvn26 khvn26 deleted the chore/log-error-on-wait-for-db branch April 22, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants