From da2a3db583c515f511b5515a56df836455174a94 Mon Sep 17 00:00:00 2001 From: Dragomir Penev Date: Fri, 10 Jan 2025 18:09:17 +0200 Subject: [PATCH] Try to suppress oversee users --- src/relations/db.py | 4 ---- src/relations/postgresql_provider.py | 4 +++- tests/integration/test_db_admin.py | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/relations/db.py b/src/relations/db.py index 48037da99a..db10935c65 100644 --- a/src/relations/db.py +++ b/src/relations/db.py @@ -184,10 +184,6 @@ def set_up_relation(self, relation: Relation) -> bool: if not database: database = relation.app.name - if not database: - logger.debug("No database or app name") - return - try: unit_relation_databag = relation.data[self.charm.unit] diff --git a/src/relations/postgresql_provider.py b/src/relations/postgresql_provider.py index 0fa0c75d2f..a063c42550 100644 --- a/src/relations/postgresql_provider.py +++ b/src/relations/postgresql_provider.py @@ -130,7 +130,9 @@ def _on_relation_broken(self, event: RelationBrokenEvent) -> None: def oversee_users(self) -> None: """Remove users from database if their relations were broken.""" - if not self.charm.unit.is_leader(): + if not self.charm.unit.is_leader() or not isinstance( + self._charm.unit.status, ActiveStatus + ): return delete_user = "suppress-oversee-users" not in self.charm.app_peer_data diff --git a/tests/integration/test_db_admin.py b/tests/integration/test_db_admin.py index b5b09c8bd7..db79bf3959 100644 --- a/tests/integration/test_db_admin.py +++ b/tests/integration/test_db_admin.py @@ -57,6 +57,8 @@ async def test_landscape_scalable_bundle_db(ops_test: OpsTest, charm: str) -> No relation_name=RELATION_NAME, timeout=3000, ) + await ops_test.model.wait_for_idle(apps=[DATABASE_APP_NAME], status="active", timeout=1000) + await check_databases_creation( ops_test, [