-
Notifications
You must be signed in to change notification settings - Fork 72
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
pass PGPASSWORD via env directly, not via shell #939
Conversation
with this, nothing uses and one more thing: technically |
88d642b
to
f71c81d
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.
Agreed on cleaning up hidden_patterns if it's not used.
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.
Overall I think this is OK, but the whole module looks rather inconsistent.
cmd, env = psql_command(config) | ||
cmd += ' -c "SHOW server_version" -t -A' | ||
version_string = execute!(cmd, :env => env) |
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.
It feels like this should use psql('SHOW server_version')
, but you probably also saw that and considered it out of scope.
And as always, I think it should have used --no-align
instead of -A
to make the comment above it redundant.
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.
maybe, but I also didn't feel like actually touching the code here
I've just realized that while this fixes one issue with the passwords, it doesn't fix the one in the report. 🤦♀️ |
I wonder if it could wrap django's dbshell command to run queries somehow |
Don't give me ideas |
PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/etc/pulp python -c 'import yaml; import settings; print(yaml.safe_dump(settings.DATABASES["default"]))' |
My biggest issue is that the Rails equivalent needs to load the entire Rails env, which is slow. And there is none (that I know of) for Candlepin. Not that we need queries on that after we merge #940, but there's still the backup/restore part. |
Nit: I'd prefer JSON and you can use |
sure, why not: # PULP_SETTINGS=/etc/pulp/settings.py pulpcore-manager shell --command 'from django.conf import settings; import json; print(json.dumps(settings.DATABASES["default"]))'
{"ENGINE": "django.db.backends.postgresql", "NAME": "pulpcore", "USER": "pulp", "PASSWORD": "sdfsfds\"dssdfdsf", "HOST": "remotedb", "PORT": "5432", "ATOMIC_REQUESTS": false, "AUTOCOMMIT": true, "CONN_MAX_AGE": 0, "CONN_HEALTH_CHECKS": false, "OPTIONS": {}, "TIME_ZONE": null, "TEST": {"CHARSET": null, "COLLATION": null, "MIGRATE": true, "MIRROR": null, "NAME": null}} |
The reason I bring it up is that it's probably easier to reuse this once we start using containers. If we start using env vars or secrets, that'll work at runtime but it'll be complex to parse all the options. |
dropped the (empty) command runner tests and added a bunch of base_database tests instead |
I wanted to know how I'd structure it and in #945 there are the results of my refactor. The biggest change is that instead of composing complex commands I pass all PG connection params via env vars which simplifies a lot of the code. I can add your tests if you'd like (and adopt where needed). |
I think that'd be a good idea, but maybe just merge this and then use yours as further improvement? |
This is done now.
I'm not sure I like refactoring it twice shortly after each other. |
Strictly speaking this one was never intended as refactoring, just fixing the bug we have when the password contains quotes ;) |
closing in favor of #945 |
No description provided.