@@ -2157,35 +2157,43 @@ def relations_user_databases_map(self) -> dict:
2157
2157
if not self .is_cluster_initialised or not self ._patroni .member_started :
2158
2158
return {USER : "all" , REPLICATION_USER : "all" , REWIND_USER : "all" }
2159
2159
user_database_map = {}
2160
- for user in sorted (
2161
- self .postgresql .list_users_from_relation (current_host = self .is_connectivity_enabled )
2162
- ):
2163
- user_database_map [user ] = "," .join (
2164
- sorted (
2165
- self .postgresql .list_accessible_databases_for_user (
2166
- user , current_host = self .is_connectivity_enabled
2160
+ try :
2161
+ for user in sorted (
2162
+ self .postgresql .list_users_from_relation (current_host = self .is_connectivity_enabled )
2163
+ ):
2164
+ user_database_map [user ] = "," .join (
2165
+ sorted (
2166
+ self .postgresql .list_accessible_databases_for_user (
2167
+ user , current_host = self .is_connectivity_enabled
2168
+ )
2167
2169
)
2168
2170
)
2169
- )
2170
- # Add "landscape" superuser by default to the list when the "db-admin" relation is present
2171
- # or when the "database" relation has "extra-user-roles" set to "SUPERUSER" (which may mean
2172
- # that PgBouncer is related to the database and there is the possibility that Landscape
2173
- # is related to it).
2174
- if any (
2175
- True
2176
- for relation in self .client_relations
2177
- if relation .name == "db-admin" # Possibly Landscape relation.
2178
- or (
2179
- relation .name == "database"
2180
- and relation .data [relation .app ].get ("extra-user-roles" ) == "SUPERUSER"
2181
- ) # PgBouncer (which may be related to Landscape).
2182
- ):
2183
- user_database_map ["landscape" ] = "all"
2184
- if self .postgresql .list_access_groups (current_host = self .is_connectivity_enabled ) != set (
2185
- ACCESS_GROUPS
2186
- ):
2187
- user_database_map .update ({USER : "all" , REPLICATION_USER : "all" , REWIND_USER : "all" })
2188
- return user_database_map
2171
+ # Add "landscape" superuser by default to the list when the "db-admin" relation is present
2172
+ # or when the "database" relation has "extra-user-roles" set to "SUPERUSER" (which may mean
2173
+ # that PgBouncer is related to the database and there is the possibility that Landscape
2174
+ # is related to it).
2175
+ if any (
2176
+ True
2177
+ for relation in self .client_relations
2178
+ if relation .name == "db-admin" # Possibly Landscape relation.
2179
+ or (
2180
+ relation .name == "database"
2181
+ and relation .data [relation .app ].get ("extra-user-roles" ) == "SUPERUSER"
2182
+ ) # PgBouncer (which may be related to Landscape).
2183
+ ):
2184
+ user_database_map ["landscape" ] = "all"
2185
+ if self .postgresql .list_access_groups (
2186
+ current_host = self .is_connectivity_enabled
2187
+ ) != set (ACCESS_GROUPS ):
2188
+ user_database_map .update ({
2189
+ USER : "all" ,
2190
+ REPLICATION_USER : "all" ,
2191
+ REWIND_USER : "all" ,
2192
+ })
2193
+ return user_database_map
2194
+ except PostgreSQLListUsersError :
2195
+ logger .debug ("relations_user_databases_map: Unable to get users" )
2196
+ return {USER : "all" , REPLICATION_USER : "all" , REWIND_USER : "all" }
2189
2197
2190
2198
def override_patroni_restart_condition (
2191
2199
self , new_condition : str , repeat_cause : str | None
0 commit comments