Repository: rucio/rucio

Issue:
Internal server error when listing another account's quota
Motivation
----------
I see this with both 1.22.5 and 1.22.7 clients:

```
> rucio list-account-usage cclement
+---------------------------------+------------+-----------+--------------+
| RSE                             | USAGE      | LIMIT     | QUOTA LEFT   |
|---------------------------------+------------+-----------+--------------|
| CERN-PROD_DET-TILE              | 130.917 GB | 0.000 B   | 0.000 B      |
| SE-SNIC-T2_STHLM_LOCALGROUPDISK | 8.984 TB   | 18.802 TB | 9.817 TB     |
| TRIUMF-LCG2_PERF-JETS           | 160.376 MB | 0.000 B   | 0.000 B      |
+---------------------------------+------------+-----------+--------------+
2020-06-04 18:44:32,014	ERROR	An unknown exception occurred.
Details: no error information passed (http status code: 500 ('internal_server_error', 'server_error', '/o\\', '\xe2\x9c\x97'))
```
however it's fine for my own quota and if I change my account to ddmadmin I don't get the error for other people's quotas, so I suspect it's a permission error when showing global quotas.

Modification
------------
Show global quotas instead of server error.




Discussion:
Hi David, 
Can you try to point the client to the integration servers? (rucio-server-int-01 from within CERN)?
Hi Martin,
Still the same issue:
```
[dcameron@lxplus796] ~> rucio -H http://rucio-server-int-01.cern.ch list-account-usage cclement
+---------------------------------+------------+-----------+--------------+
| RSE                             | USAGE      | LIMIT     | QUOTA LEFT   |
|---------------------------------+------------+-----------+--------------|
| CERN-PROD_DET-TILE              | 130.917 GB | 0.000 B   | 0.000 B      |
| SE-SNIC-T2_STHLM_LOCALGROUPDISK | 8.984 TB   | 18.802 TB | 9.817 TB     |
| TRIUMF-LCG2_PERF-JETS           | 160.376 MB | 0.000 B   | 0.000 B      |
+---------------------------------+------------+-----------+--------------+
2020-06-05 10:22:58,640	ERROR	An unknown exception occurred.
Details: no error information passed (http status code: 500 ('internal_server_error', 'server_error', '/o\\', '\xe2\x9c\x97'))
```
@bziemons can you please have a look at this? This might be related to an error in the atlas/generic permission file.
@bari12 The fix is similar to #3657, PR is submitted.
This issue has reappeared since 1.23.0 was deployed.
@bari12 do you know what happened?

Resolving patch:
diff --git a/lib/rucio/core/permission/generic.py b/lib/rucio/core/permission/generic.py
--- a/lib/rucio/core/permission/generic.py
+++ b/lib/rucio/core/permission/generic.py
@@ -891,12 +891,7 @@ def perm_get_global_account_usage(issuer, kwargs):
     admin_in_country = set()
     for kv in list_account_attributes(account=issuer):
         if kv['key'].startswith('country-') and kv['value'] == 'admin':
-            admin_in_country.add(kv['key'].partition('-')[2])
-    resolved_rse_countries = {list_rse_attributes(rse_id=rse['rse_id']).get('country')
-                              for rse in parse_expression(kwargs['rse_expression'], filter={'vo': issuer.vo})}
-
-    if resolved_rse_countries.issubset(admin_in_country):
-        return True
+            return True
     return False
 
 


Test patch: