File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
tests/integration/ha_tests Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 92
92
93
93
PRIMARY_NOT_REACHABLE_MESSAGE = "waiting for primary to be reachable from this unit"
94
94
EXTENSIONS_DEPENDENCY_MESSAGE = "Unsatisfied plugin dependencies. Please check the logs"
95
+ DIFFERENT_VERSIONS_PSQL_BLOCKING_MESSAGE = (
96
+ "Please select the correct version of postgresql to use. No need to use different versions of postgresql."
97
+ )
95
98
96
99
Scopes = Literal [APP_SCOPE , UNIT_SCOPE ]
97
100
@@ -466,6 +469,10 @@ def _on_peer_relation_changed(self, event: HookEvent):
466
469
event .defer ()
467
470
return
468
471
472
+ if not self .validate_database_version (self ._patroni .get_postgresql_version ()):
473
+ self .unit .status = BlockedStatus (DIFFERENT_VERSIONS_PSQL_BLOCKING_MESSAGE )
474
+ return
475
+
469
476
if self ._update_member_ip ():
470
477
return
471
478
@@ -1577,6 +1584,15 @@ def client_relations(self) -> List[Relation]:
1577
1584
relations .append (relation )
1578
1585
return relations
1579
1586
1587
+ def validate_database_version (self , version : str ) -> bool :
1588
+ peer_db_version = self .app_peer_data .get ("database-version" )
1589
+
1590
+ if self .unit .is_leader () and peer_db_version is None :
1591
+ self .app_peer_data .update ({"database-version" : version })
1592
+ return True
1593
+
1594
+ return peer_db_version == self ._patroni .get_postgresql_version ()
1595
+
1580
1596
1581
1597
if __name__ == "__main__" :
1582
1598
main (PostgresqlOperatorCharm )
Original file line number Diff line number Diff line change @@ -578,6 +578,8 @@ async def test_deploy_zero_units(ops_test: OpsTest, charm):
578
578
logger .info ("connect to DB and create test table" )
579
579
await create_test_data (connection_string )
580
580
581
+ # TODO: implement a test using the store with a different version of Postgres
582
+
581
583
unit_ip_addresses = []
582
584
primary_storage = ""
583
585
for unit in ops_test .model .applications [app ].units :
You can’t perform that action at this time.
0 commit comments