Skip to content

Commit c7a4832

Browse files
authored
Filter out users with no database (#1555)
1 parent 3916f03 commit c7a4832

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/charm.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,13 +2432,16 @@ def relations_user_databases_map(self) -> dict:
24322432
"rewind",
24332433
):
24342434
continue
2435-
user_database_map[user] = ",".join(
2435+
if databases := ",".join(
24362436
sorted(
24372437
self.postgresql.list_accessible_databases_for_user(
24382438
user, current_host=self.is_connectivity_enabled
24392439
)
24402440
)
2441-
)
2441+
):
2442+
user_database_map[user] = databases
2443+
else:
2444+
logger.debug(f"User {user} has no databases to connect to")
24422445
# Add "landscape" superuser by default to the list when the "db-admin" relation is present
24432446
# or when the "database" relation has "extra-user-roles" set to "SUPERUSER" (which may mean
24442447
# that PgBouncer is related to the database and there is the possibility that Landscape

0 commit comments

Comments
 (0)