Merge ~cjwatson/launchpad-layers:set-role-after-connecting into launchpad-layers:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 819dd81912f69d759d72b294936c084ac227c18b
Proposed branch: ~cjwatson/launchpad-layers:set-role-after-connecting
Merge into: launchpad-layers:main
Diff against target: 46 lines (+1/-6)
3 files modified
launchpad-base/lib/charms/launchpad/base.py (+0/-1)
launchpad-base/reactive/launchpad-base.py (+0/-5)
launchpad-base/templates/launchpad-base-lazr.conf (+1/-0)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+439168@code.launchpad.net

Commit message

Set database role after connecting

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍🏼

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/launchpad-base/lib/charms/launchpad/base.py b/launchpad-base/lib/charms/launchpad/base.py
2index 71f0dbe..2a182fe 100644
3--- a/launchpad-base/lib/charms/launchpad/base.py
4+++ b/launchpad-base/lib/charms/launchpad/base.py
5@@ -190,6 +190,5 @@ def update_pgpass(dsn):
6
7 def strip_dsn_authentication(dsn):
8 parsed_dsn = parse_dsn(dsn)
9- parsed_dsn.pop("user", None)
10 parsed_dsn.pop("password", None)
11 return make_dsn(**parsed_dsn)
12diff --git a/launchpad-base/reactive/launchpad-base.py b/launchpad-base/reactive/launchpad-base.py
13index b3bd439..0015a78 100644
14--- a/launchpad-base/reactive/launchpad-base.py
15+++ b/launchpad-base/reactive/launchpad-base.py
16@@ -21,7 +21,6 @@ from charms.reactive import (
17 when_not,
18 )
19 from ols import base, postgres
20-from psycopg2.extensions import parse_dsn
21
22
23 # Monkey-patch layer:ols.
24@@ -73,10 +72,6 @@ def configure():
25 config["db_standby"] = ",".join(
26 strip_dsn_authentication(dsn) for dsn in db_standby
27 )
28- # XXX cjwatson 2022-09-23: This is a layering violation, since it's
29- # specific to the appserver. We need to teach Launchpad to be able to
30- # log in as one role and then switch to another.
31- config["db_user"] = parse_dsn(db_primary)["user"]
32 config["rabbitmq_broker_urls"] = sorted(get_rabbitmq_uris(rabbitmq))
33 configure_lazr(
34 config,
35diff --git a/launchpad-base/templates/launchpad-base-lazr.conf b/launchpad-base/templates/launchpad-base-lazr.conf
36index 9e597f5..748aaa2 100644
37--- a/launchpad-base/templates/launchpad-base-lazr.conf
38+++ b/launchpad-base/templates/launchpad-base-lazr.conf
39@@ -47,6 +47,7 @@ git_ssh_root: git+ssh://{{ domain_git }}/
40 {{- opt("db_statement_timeout", db_statement_timeout) }}
41 rw_main_primary: {{ db_primary }}
42 rw_main_standby: {{ db_standby or db_primary }}
43+set_role_after_connecting: True
44 {{- opt("soft_request_timeout", soft_request_timeout) }}
45
46 [error_reports]

Subscribers

People subscribed via source and target branches