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

Allow configuring database engine via db config key #8287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MagicRB
Copy link
Contributor

@MagicRB MagicRB commented Jan 10, 2025

Contributor Checklist:

  • I have updated the unit tests
  • I have created a file in the newsfragments directory (and read the README.txt in that directory)
  • I have updated the appropriate documentation

_

So I'm not sure if this is the way to do it, config['db'] goes from only having db_url as the only allowed key to allowing anything and passing all of it except for db_url to the backing DB engine. If this approach is fine ill write up the docs, newsfragments and all the rest.

@MagicRB MagicRB force-pushed the allow-configuring-db-engine branch from 81f2d41 to 8f8546e Compare January 10, 2025 14:00
Signed-off-by: magic_rb <richard@brezak.sk>
@MagicRB MagicRB force-pushed the allow-configuring-db-engine branch from 8f8546e to b152da0 Compare January 10, 2025 14:03
@p12tic
Copy link
Member

p12tic commented Jan 10, 2025

Just to confirm - have you checked that it's not possible to pass the DB client configuration that you need via the URL parameters? There's fair amount of configuration possible, e.g. postgresql+psycopg2://user:pass@host/dbname?alt_host=host1&alt_host=host2&ssl_cipher=%2Fpath%2Fto%2Fcrt.


def load_db(self, filename, config_dict):
self.db = {"db_url": self.getDbUrlFromConfig(config_dict)}
self.db = self.getDbFromConfig(config_dict)
Copy link
Member

Choose a reason for hiding this comment

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

snake_case for changed code

@@ -85,7 +85,7 @@ def __init__(self, basedir):

# not configured yet - we don't build an engine until the first
# reconfig
self.configured_url = None
self.configured_db = None
Copy link
Member

Choose a reason for hiding this comment

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

configured_db_config


db_url = self.configured_url
db_config = dict(self.configured_db)
Copy link
Member

Choose a reason for hiding this comment

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

I think self.configured_db.copy() would be more explicit of what's happening

p = Properties()
p.master = self
return p.render(new_config.db['db_url'])
Copy link
Member

Choose a reason for hiding this comment

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

You can simply return p.render(new_config.db) which will render values of the dict automatically


db_url = self.configured_url
db_config = dict(self.configured_db)
Copy link
Member

Choose a reason for hiding this comment

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

I think that we should put sqlalchemy kwargs into separate key. E.g. engine_kwargs to make it clear where they are used. This would make buildbot config structure more self descriptive.

@p12tic
Copy link
Member

p12tic commented Jan 10, 2025

Overall idea makes sense, I left several comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants