Skip to content

Commit

Permalink
Try to suppress oversee users
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomirp committed Jan 10, 2025
1 parent 142bcd8 commit da2a3db
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 0 additions & 4 deletions src/relations/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
4 changes: 3 additions & 1 deletion src/relations/postgresql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_db_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand Down

0 comments on commit da2a3db

Please sign in to comment.