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

Fixes bug 1137879 add support for postgres:// or postgresql:// URLs #2647

Conversation

selenamarie
Copy link
Contributor

No description provided.


from configman.config_manager import RequiredConfig
from configman import Namespace

urlparse.uses_netloc.append('postgres')
urlparse.uses_netloc.append('postgresql')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These might require a comment. Why is it needed? Also, the first part of a URI is usually called the "scheme" E.g. "ftp" but this talks about "netloc" which is usually the alias for "hostname".

@peterbe
Copy link
Contributor

peterbe commented Mar 4, 2015

Two things:

  1. The problem with port==None being inserted into the self.dsn string would still become "... port=None ..." as a string.

  2. I don't like the DSN. I think we should use keywords arguments instead. Is that out of scope here?

@twobraids
Copy link
Contributor

I see a potential problem. the PG connection context will likely be embedded in namespaces, perhaps several deep. that would mean that in order for configman to grab the value of the URL from the environment, the environment var would have to reflect that same nesting.

Do you want to have this PG URL behavior for all the Socorro apps, or do you have it in mind just for one in particular?

@selenamarie
Copy link
Contributor Author

@twobraids we need support for this in all apps. I had originally made a similar change in setupdb_app.py, and then realized this was needed everywhere, so I figured that I could set it in connection_context and rely on the common_database.ini to cover most of our use cases.

In my AWS instance, I'm using the integration test command-line invocations that use resource.postgresql and that seems to not require additional tweaking.

@selenamarie
Copy link
Contributor Author

Note from IRC conversation: resources__postgresql__database_url is the environment variable needed to override configuration of the URL in production.

@peterbe peterbe self-assigned this Mar 18, 2015
default='postgres://test:aPassword@localhost:5432/socorro_integration_test',
doc='Name of database to manage',
)
required_config.add_option(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why keep these old options then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying not to make the heroku-specific stuff be mandatory. Having the password embedded in the URL might be an issue for some users as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a URL isn't Heroku-specific. I use it whenever I can when I do non-django. The reason I like it is because it files into one environment variable instead of 5.
Also, wherever you type in database_password you'd also type in database_url.

Either way, I'm not convinced. But I am convinced that you know better. :)
My comment was just a question after all :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth exploring the rest of the changes in another PR. It's just a lot of code change that touches a bunch of things like integration tests, so I'd like to take this step now, and rip out the rest of the stuff later.

That said.. I'll try it right now and see how many things need to be altered to support it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exploration revealed depedencies on socorro.database.database in our tests and middleware. Going back to just supporting the minimal change of adding support for database_url without deprecating DSN, pending deprecation of socorro.database.database.

@selenamarie selenamarie force-pushed the nobug-support-heroku-in-ext-postgres branch 2 times, most recently from 2911d61 to 516b799 Compare March 27, 2015 17:43
@@ -8,23 +8,27 @@ JENKINS_CONF=jenkins.py.dist

ENV=env

PYTHONPATH="."
PYTHONPATH='.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Why quotation at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's debugging cruft. There's no need for the quotes, so I'll just remove them when I add comments about deprecation.

@peterbe
Copy link
Contributor

peterbe commented Mar 31, 2015

r+ with some optional nits

* remove testing change to database username
* Move urlparse to Database object for commonconfig
* Fix defaults for database_url and PEP8
* Use kwargs if available for postgres context manager
* Updates rabbitmq integration test for database_url
* Create a better URL based on --database_url
* Set default for database_url in connection pooling to None
* Add resource.postgresql.database_url to crontabber setup
@selenamarie selenamarie force-pushed the nobug-support-heroku-in-ext-postgres branch from 9702b0a to 9075998 Compare March 31, 2015 16:51
@twobraids
Copy link
Contributor

I am replacing this PR with one that does not suffer override ambiguities.

@twobraids twobraids closed this Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants