Repository: rucio/rucio

Issue:
core.account_limit.get_rse_account_usage should liste accounts who have usage, but no quota
Motivation
----------
Due to the join of the two tables, only accounts with usage and quota are listed, however, accounts without quota should be listed as well.


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/account_limit.py b/lib/rucio/core/account_limit.py
--- a/lib/rucio/core/account_limit.py
+++ b/lib/rucio/core/account_limit.py
@@ -1,16 +1,21 @@
-'''
-  Copyright European Organization for Nuclear Research (CERN)
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  You may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Authors:
-  - Martin Barisits, <martin.barisits@cern.ch>, 2013-2015
-  - Cedric Serfon, <cedric.serfon@cern.ch>, 2015
-  - Vincent Garonne, <vincent.garonne@cern.ch>, 2015
-'''
+# Copyright 2013-2018 CERN for the benefit of the ATLAS collaboration.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Authors:
+#  - Martin Barisits, <martin.barisits@cern.ch>, 2013-2018
+#  - Cedric Serfon, <cedric.serfon@cern.ch>, 2015
+#  - Vincent Garonne, <vincent.garonne@cern.ch>, 2015
 
 from sqlalchemy.orm.exc import NoResultFound
 from sqlalchemy.sql.expression import and_, or_
@@ -32,7 +37,7 @@ def get_rse_account_usage(rse, session=None):
     result = []
     rse_id = get_rse_id(rse=rse, session=session)
     query = session.query(models.AccountUsage.account, models.AccountUsage.files, models.AccountUsage.bytes, models.AccountLimit.bytes)
-    query = query.join(models.AccountLimit, and_(models.AccountUsage.account == models.AccountLimit.account, models.AccountUsage.rse_id == models.AccountLimit.rse_id)).filter(models.AccountUsage.rse_id == rse_id)
+    query = query.outerjoin(models.AccountLimit, and_(models.AccountUsage.account == models.AccountLimit.account, models.AccountUsage.rse_id == models.AccountLimit.rse_id)).filter(models.AccountUsage.rse_id == rse_id)
     account_limits_tmp = query.all()
     for row in account_limits_tmp:
         result.append({'rse': rse, 'account': row[0], 'used_files': row[1], 'used_bytes': row[2], 'quota_bytes': row[3]})


Test patch:
diff --git a/lib/rucio/tests/test_meta.py b/lib/rucio/tests/test_meta.py
--- a/lib/rucio/tests/test_meta.py
+++ b/lib/rucio/tests/test_meta.py
@@ -10,6 +10,7 @@
 
 from nose.tools import assert_true, assert_in, raises, assert_is_instance
 
+from rucio.db.sqla.constants import DIDType
 from rucio.client.metaclient import MetaClient
 from rucio.common.exception import KeyNotFound, InvalidValueForKey, UnsupportedValueType
 from rucio.common.utils import generate_uuid as uuid
@@ -78,3 +79,7 @@ def xtest_add_value_to_bad_key(self):
         """ META (CLIENTS):  Add a new value to a non existing key """
         value = 'value_' + str(uuid())
         self.meta_client.add_value(key="Nimportnawak", value=value)
+
+    def xtest_add_key_mysql(self):
+        """ META (CORE): Add a new key to test conversions on MySQL"""
+        self.meta_client.add_key('datatype', DIDType.FILE)