Repository: rucio/rucio

Issue:
Integer attribute value '1' displayed as 'True' in the client.  
Motivation
----------
Rucio 1.20.2 and earlier, when the attribute value is set to an integer (e.g. for key='tier'), the value='1' is displayed as 'True' in the client output. Similarly, '0' is shown as 'False'. 

Modification
------------
According to FIXME comment in https://github.com/rucio/rucio/blob/5299d7b9b0e0c5240369916b7f05790a6f12b841/lib/rucio/db/sqla/types.py#L114-L120 this is a temporary work around legacy values in the ATLAS database, which should be removed after the database is fixed. 




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/rse.py b/lib/rucio/core/rse.py
--- a/lib/rucio/core/rse.py
+++ b/lib/rucio/core/rse.py
@@ -325,19 +325,8 @@ def list_rses(filters={}, session=None):
             else:
                 t = aliased(models.RSEAttrAssociation)
                 query = query.join(t, t.rse_id == models.RSEAttrAssociation.rse_id)
-                query = query.filter(t.key == k)
-
-                # FIXME
-                # ATLAS RSE listing workaround (since booleans are capital 'True'/'False')
-                # remove elif branch after appropriate database fix has been applied
-                # see also db/types.py
-                if isinstance(v, bool):
-                    query = query.filter(or_(t.value == v,
-                                             t.value == 'tmp_atlas_%s' % v,
-                                             t.value == 'tmp_atlas_%s' % 1 if v else 0))
-                else:
-                    query = query.filter(or_(t.value == v,
-                                             t.value == 'tmp_atlas_%s' % v))
+                query = query.filter(t.key == k,
+                                     t.value == v)
 
         condition1, condition2 = [], []
         for i in range(0, 8):
diff --git a/lib/rucio/db/sqla/types.py b/lib/rucio/db/sqla/types.py
--- a/lib/rucio/db/sqla/types.py
+++ b/lib/rucio/db/sqla/types.py
@@ -98,12 +98,6 @@ def process_bind_param(self, value, dialect):
                 return 'true'
             elif value.lower() == 'false':
                 return 'false'
-            # FIXME
-            # ATLAS RSE listing workaround (since booleans are capital 'True'/'False')
-            # remove elif branch after appropriate database fix has been applied
-            # see also core/rse.py
-            elif value.startswith('tmp_atlas_'):
-                return value[10:]
 
         return str(value)
 
@@ -111,12 +105,9 @@ def process_result_value(self, value, dialect):
         if value is None:
             return value
 
-        # FIXME
-        # be backward compatible for now by still including 0/1 as acceptable booleans
-        # remove 0/1 after appropriate database fix has been applied
-        if value.lower() in ['1', 'true']:
+        if value.lower() == 'true':
             return True
-        elif value.lower() in ['0', 'false']:
+        elif value.lower() == 'false':
             return False
         else:
             return value


Test patch:
diff --git a/lib/rucio/tests/test_boolean.py b/lib/rucio/tests/test_boolean.py
--- a/lib/rucio/tests/test_boolean.py
+++ b/lib/rucio/tests/test_boolean.py
@@ -55,9 +55,9 @@ def test_booleanstring_account_attribute(self):
                 result[res['key']] = res['value']
 
         assert_equal(result['teststringtrue'], True)
-        assert_equal(result['testinttrue'], True)
+        assert_equal(result['testinttrue'], '1')
         assert_equal(result['teststringfalse'], False)
-        assert_equal(result['testintfalse'], False)
+        assert_equal(result['testintfalse'], '0')
 
     def test_booleanstring_rse_attribute(self):
         self.rse_client.add_rse_attribute(self.rse, 'teststringtrue', 'true')
@@ -69,6 +69,6 @@ def test_booleanstring_rse_attribute(self):
         result = self.rse_client.list_rse_attributes(self.rse)
 
         assert_equal(result['teststringtrue'], True)
-        assert_equal(result['testinttrue'], True)
+        assert_equal(result['testinttrue'], '1')
         assert_equal(result['teststringfalse'], False)
-        assert_equal(result['testintfalse'], False)
+        assert_equal(result['testintfalse'], '0')