-
Notifications
You must be signed in to change notification settings - Fork 0
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
[PP-1775] Ensure ssl connections to postgres work when ssl required #286
[PP-1775] Ensure ssl connections to postgres work when ssl required #286
Conversation
d39ee8c
to
0f19917
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #286 +/- ##
=======================================
Coverage 88.15% 88.15%
=======================================
Files 37 37
Lines 2271 2271
Branches 304 304
=======================================
Hits 2002 2002
Misses 215 215
Partials 54 54 ☔ View full report in Codecov by Sentry. |
d025abf
to
d69aeea
Compare
492ff49
to
de5e2f4
Compare
…uired. Additional updates: * upgrades image to python 3.12 * upgrades postgres to 16 (to match latest RDS deployment)
de5e2f4
to
c19bb60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a few comments that would be good to clean up before merging.
There is also a reference to postgres:12
in the README that should get updated to postgres:16
virtual-library-card/README.md
Lines 142 to 146 in 1b1c78c
### 2. Create PostgreSQL Container (Only for testing) | |
Either create a new database in the production PostgreSQL Database. Or use the docker PostgreSQL container for testing. | |
docker run -d --name pg --rm -e POSTGRES_USER=vlc -e POSTGRES_PASSWORD=test -e POSTGRES_DB=virtual_library_card postgres:12 |
Dockerfile
Outdated
@@ -1,4 +1,4 @@ | |||
FROM python:3.10-slim | |||
FROM python:3.12-slim |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change updates the Python version in the container to Python 3.12. Probably don't want to make this change until we update CI to test against Python 3.12 as well. Maybe leave this at Python 3.10 for now, since all our other containers are using 3.10 at the moment.
Dockerfile
Outdated
# required for postgres ssl: the crt file doesn't exist | ||
# but the path must point to a visible directory otherwise we | ||
# get a permissions error | ||
ENV PGSSLCERT /tmp/postgresql.crt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should update this to the new env var format to fix the deprecation warning.
ENV PGSSLCERT /tmp/postgresql.crt | |
ENV PGSSLCERT=/tmp/postgresql.crt |
command: > | ||
-c ssl=on | ||
-c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem | ||
-c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be helpful to our future selves to add a comment here about why these lines are required. I'm thinking something like:
AWS RDS requires SSL, so we enable SSL for the database with a self signed snakeoil cert, so this database mimics the production databases as closely as we can.
tox.ini
Outdated
environment = | ||
POSTGRES_USER=vlc | ||
POSTGRES_PASSWORD=test | ||
POSTGRES_DB=test_virtual_library_card_dev | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Unnecessary space added
tox.ini
Outdated
@@ -14,6 +14,8 @@ docker = | |||
docker: minio-vlc | |||
setenv = | |||
COVERAGE_FILE = .coverage.{envname} | |||
PG_SSL_MODE = allow | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Unnecessary space added
virtual_library_card/settings/dev.py
Outdated
@@ -22,6 +22,7 @@ | |||
"PASSWORD": "test", | |||
"HOST": os.environ.get("VLC_DEV_DB_HOST", "pg"), | |||
"PORT": os.environ.get("VLC_DEV_DB_PORT", "5432"), | |||
"OPTIONS": {"sslmode": os.environ.get("PG_SSL_MODE", "require")}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should follow the same naming scheme we already have for these environment variables. Based on the name, I assumed it was a PG environment variable and I was looking in the PG docs to try to figure out what it did, until I found it defined here.
I'd suggest something like VLC_DEV_DB_SSL_MODE
.
Thank you for the thorough review :) |
Description
When we upgraded to Postgres 16 in the tpp-dev environment, VLC was failing because PG 16 requires SSL connections by default.
This update fixes the problem in the docker container. In order to verify SSL connections are happening I enabled SSL for postgres 16 in the docker compose script and for extra certainty that the client is using SSL I updated the dev settings to specify the pg ssl mode.
THIS PR should be merged after #285 is merged.
Motivation and Context
https://ebce-lyrasis.atlassian.net/browse/PP-1775
How Has This Been Tested?
Manually tested using
docker compose up
. Without the update to the docker image I was getting the same error we were seeing in tpp-dev. With it I, I am able to connect.Checklist