launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29772
[Merge] ~cjwatson/launchpad-layers:set-role-after-connecting into launchpad-layers:main
Colin Watson has proposed merging ~cjwatson/launchpad-layers:set-role-after-connecting into launchpad-layers:main.
Commit message:
Set database role after connecting
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-layers/+git/launchpad-layers/+merge/439168
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/432027 allows us to connect using a single set of user credentials provided via the `pgsql` interface, and then switch to whichever database role we need for a given task. This simplifies a lot of our deployment arrangements.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-layers:set-role-after-connecting into launchpad-layers:main.
diff --git a/launchpad-base/lib/charms/launchpad/base.py b/launchpad-base/lib/charms/launchpad/base.py
index 71f0dbe..2a182fe 100644
--- a/launchpad-base/lib/charms/launchpad/base.py
+++ b/launchpad-base/lib/charms/launchpad/base.py
@@ -190,6 +190,5 @@ def update_pgpass(dsn):
def strip_dsn_authentication(dsn):
parsed_dsn = parse_dsn(dsn)
- parsed_dsn.pop("user", None)
parsed_dsn.pop("password", None)
return make_dsn(**parsed_dsn)
diff --git a/launchpad-base/reactive/launchpad-base.py b/launchpad-base/reactive/launchpad-base.py
index b3bd439..559410e 100644
--- a/launchpad-base/reactive/launchpad-base.py
+++ b/launchpad-base/reactive/launchpad-base.py
@@ -73,10 +73,6 @@ def configure():
config["db_standby"] = ",".join(
strip_dsn_authentication(dsn) for dsn in db_standby
)
- # XXX cjwatson 2022-09-23: This is a layering violation, since it's
- # specific to the appserver. We need to teach Launchpad to be able to
- # log in as one role and then switch to another.
- config["db_user"] = parse_dsn(db_primary)["user"]
config["rabbitmq_broker_urls"] = sorted(get_rabbitmq_uris(rabbitmq))
configure_lazr(
config,
diff --git a/launchpad-base/templates/launchpad-base-lazr.conf b/launchpad-base/templates/launchpad-base-lazr.conf
index 9e597f5..748aaa2 100644
--- a/launchpad-base/templates/launchpad-base-lazr.conf
+++ b/launchpad-base/templates/launchpad-base-lazr.conf
@@ -47,6 +47,7 @@ git_ssh_root: git+ssh://{{ domain_git }}/
{{- opt("db_statement_timeout", db_statement_timeout) }}
rw_main_primary: {{ db_primary }}
rw_main_standby: {{ db_standby or db_primary }}
+set_role_after_connecting: True
{{- opt("soft_request_timeout", soft_request_timeout) }}
[error_reports]