Merge lp:~sajoupa/landscape-charm/op-framework-fixes into lp:~mitchburton/landscape-charm/op-framework

Proposed by Laurent Sesquès
Status: Merged
Approved by: Mitch Burton
Approved revision: 427
Merge reported by: Mitch Burton
Merged at revision: not available
Proposed branch: lp:~sajoupa/landscape-charm/op-framework-fixes
Merge into: lp:~mitchburton/landscape-charm/op-framework
Diff against target: 17 lines (+4/-3)
1 file modified
src/charm.py (+4/-3)
To merge this branch: bzr merge lp:~sajoupa/landscape-charm/op-framework-fixes
Reviewer Review Type Date Requested Status
Mitch Burton Approve
Review via email: mp+435184@code.launchpad.net

Commit message

_db_relation_changed: check that we have all needed keys from the db relation

To post a comment you must log in.
427. By Laurent Sesquès

_db_relation_changed: typo fix

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 2023-01-03 22:46:42 +0000
3+++ src/charm.py 2023-01-05 09:22:56 +0000
4@@ -257,9 +257,10 @@
5 def _db_relation_changed(self, event: RelationChangedEvent) -> None:
6 unit_data = event.relation.data[event.unit]
7
8- # Using "master" key as a quick indicator of readiness.
9- if "master" not in unit_data:
10- logger.info("db relation not yet ready")
11+ required_relation_data = ["master", "allowed-units", "port", "user"]
12+ missing_relation_data = [i for i in required_relation_data if i not in unit_data]
13+ if missing_relation_data:
14+ logger.info("db relation not yet ready. Missing keys: {}".format(missing_relation_data))
15 self.unit.status = ActiveStatus("Unit is ready")
16 self._update_ready_status()
17 return

Subscribers

People subscribed via source and target branches

to all changes: