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
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):
190190
191def strip_dsn_authentication(dsn):191def strip_dsn_authentication(dsn):
192 parsed_dsn = parse_dsn(dsn)192 parsed_dsn = parse_dsn(dsn)
193 parsed_dsn.pop("user", None)
194 parsed_dsn.pop("password", None)193 parsed_dsn.pop("password", None)
195 return make_dsn(**parsed_dsn)194 return make_dsn(**parsed_dsn)
diff --git a/launchpad-base/reactive/launchpad-base.py b/launchpad-base/reactive/launchpad-base.py
index b3bd439..0015a78 100644
--- a/launchpad-base/reactive/launchpad-base.py
+++ b/launchpad-base/reactive/launchpad-base.py
@@ -21,7 +21,6 @@ from charms.reactive import (
21 when_not,21 when_not,
22)22)
23from ols import base, postgres23from ols import base, postgres
24from psycopg2.extensions import parse_dsn
2524
2625
27# Monkey-patch layer:ols.26# Monkey-patch layer:ols.
@@ -73,10 +72,6 @@ def configure():
73 config["db_standby"] = ",".join(72 config["db_standby"] = ",".join(
74 strip_dsn_authentication(dsn) for dsn in db_standby73 strip_dsn_authentication(dsn) for dsn in db_standby
75 )74 )
76 # XXX cjwatson 2022-09-23: This is a layering violation, since it's
77 # specific to the appserver. We need to teach Launchpad to be able to
78 # log in as one role and then switch to another.
79 config["db_user"] = parse_dsn(db_primary)["user"]
80 config["rabbitmq_broker_urls"] = sorted(get_rabbitmq_uris(rabbitmq))75 config["rabbitmq_broker_urls"] = sorted(get_rabbitmq_uris(rabbitmq))
81 configure_lazr(76 configure_lazr(
82 config,77 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 }}/
47{{- opt("db_statement_timeout", db_statement_timeout) }}47{{- opt("db_statement_timeout", db_statement_timeout) }}
48rw_main_primary: {{ db_primary }}48rw_main_primary: {{ db_primary }}
49rw_main_standby: {{ db_standby or db_primary }}49rw_main_standby: {{ db_standby or db_primary }}
50set_role_after_connecting: True
50{{- opt("soft_request_timeout", soft_request_timeout) }}51{{- opt("soft_request_timeout", soft_request_timeout) }}
5152
52[error_reports]53[error_reports]

Subscribers

People subscribed via source and target branches