Merge lp:~sajoupa/landscape-charm/op-framework-db-connect-to-primary into lp:~mitchburton/landscape-charm/op-framework

Proposed by Laurent Sesquès
Status: Merged
Approved by: Mitch Burton
Approved revision: 424
Merge reported by: Mitch Burton
Merged at revision: not available
Proposed branch: lp:~sajoupa/landscape-charm/op-framework-db-connect-to-primary
Merge into: lp:~mitchburton/landscape-charm/op-framework
Diff against target: 18 lines (+4/-2)
1 file modified
src/charm.py (+4/-2)
To merge this branch: bzr merge lp:~sajoupa/landscape-charm/op-framework-db-connect-to-primary
Reviewer Review Type Date Requested Status
Mitch Burton Approve
Review via email: mp+435019@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Laurent Sesquès (sajoupa) wrote :

The current version of the charm fails to deploy in CI and staging with multiple postgresql units, because it can't update the DB schema.
This is because unit_data["host"] can return the IP of any postgresql unit, including the secondary, which is read-only.
This commit will ensure that landscape-server connects to the primary.

Revision history for this message
Mitch Burton (mitchburton) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/charm.py'
2--- src/charm.py 2022-12-06 18:27:20 +0000
3+++ src/charm.py 2022-12-30 09:24:16 +0000
4@@ -268,10 +268,12 @@
5 self._stored.ready["db"] = False
6 self.unit.status = MaintenanceStatus("Setting up databases")
7
8- host = unit_data["host"]
9+ # We can't use unit_data["host"] because it can return the IP of the secondary
10+ master = dict(s.split('=', 1) for s in unit_data["master"])
11+ host = master["host"]
12+ password = master["password"]
13 port = unit_data["port"]
14 user = unit_data["user"]
15- password = unit_data["password"]
16
17 update_service_conf({
18 "stores": {

Subscribers

People subscribed via source and target branches

to all changes: