Skip to content

Commit

Permalink
fix unit fixed setting postgresql version into app_peer_data
Browse files Browse the repository at this point in the history
  • Loading branch information
BalabaDmitri committed Apr 17, 2024
1 parent d917d88 commit 0a0486f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,9 @@ def _validate_database_version(self):
peer_db_version = self.app_peer_data.get("database-version")

if self.unit.is_leader() and peer_db_version is None:
self.app_peer_data.update({"database-version": self._patroni.get_postgresql_version()})
_psql_version = self._patroni.get_postgresql_version()
if _psql_version is not None:
self.app_peer_data.update({"database-version": _psql_version})
return

if peer_db_version != self._patroni.get_postgresql_version():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ def test_on_peer_relation_changed(
self.harness.update_relation_data(
self.rel_id,
self.charm.app.name,
{"cluster_initialised": "True", "members_ips": '["1.1.1.1"]'},
{"cluster_initialised": "True", "members_ips": '["1.1.1.1"]', "database_version": "14"},
)
self.harness.set_leader()
_reconfigure_cluster.return_value = False
Expand Down

0 comments on commit 0a0486f

Please sign in to comment.