launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29773
[Merge] ~cjwatson/launchpad:charm-admin-lazr-admin-user into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-admin-lazr-admin-user into launchpad:master.
Commit message:
charm: Use admin credentials in launchpad-admin-lazr.conf
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/439170
Part of the point of the `launchpad-admin` charm is to provide a context in which we can run Launchpad code with database superuser credentials, such as for database creation or schema upgrades. This works a lot better if we actually give it superuser credentials.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-admin-lazr-admin-user into launchpad:master.
diff --git a/charm/launchpad-admin/reactive/launchpad-admin.py b/charm/launchpad-admin/reactive/launchpad-admin.py
index 6dad256..97d58c1 100644
--- a/charm/launchpad-admin/reactive/launchpad-admin.py
+++ b/charm/launchpad-admin/reactive/launchpad-admin.py
@@ -38,14 +38,18 @@ def strip_password(dsn):
def configure(db, db_admin, session_db):
config = get_service_config()
db_primary, _ = postgres.get_db_uris(db)
- db_admin_primary, _ = postgres.get_db_uris(db_admin)
+ db_admin_primary, db_admin_standby = postgres.get_db_uris(db_admin)
session_db_primary, _ = postgres.get_db_uris(session_db)
# We assume that this admin user works for any database on this host,
# which seems to be true in practice.
- update_pgpass(any_dbname(db_admin_primary))
+ for dsn in [db_admin_primary] + db_admin_standby:
+ update_pgpass(any_dbname(dsn))
update_pgpass(session_db_primary)
config["db_primary"] = strip_password(db_primary)
config["db_admin_primary"] = strip_password(db_admin_primary)
+ config["db_admin_standby"] = ",".join(
+ strip_password(dsn) for dsn in db_admin_standby
+ )
config["db_session_primary"] = strip_password(session_db_primary)
config["db_session"] = strip_dsn_authentication(session_db_primary)
config["db_session_user"] = parse_dsn(session_db_primary)["user"]
diff --git a/charm/launchpad-admin/templates/launchpad-admin-lazr.conf b/charm/launchpad-admin/templates/launchpad-admin-lazr.conf
index b652e52..24a41f9 100644
--- a/charm/launchpad-admin/templates/launchpad-admin-lazr.conf
+++ b/charm/launchpad-admin/templates/launchpad-admin-lazr.conf
@@ -11,6 +11,10 @@
[meta]
extends: ../launchpad-base-lazr.conf
+[database]
+rw_main_primary: {{ db_admin_primary }}
+rw_main_standby: {{ db_admin_standby or db_admin_primary }}
+
[launchpad_session]
database: {{ db_session }}
dbuser: {{ db_session_user }}