Repository: rucio/rucio

Issue:
all_rses option redundant for light and dark reaper
Motivation
----------

The `all_rses` option for both the light and dark reaper is immediately overwritten by `list_rses()` before checking its Boolean value. As the list returned will only evaluate to `False` in the case no RSEs exist (in which case the reaper has bigger issues) `all_rses` is effectively always `True`.

Furthermore, running either reaper without passing arguments for `include_rses`, `exclude_rses` or `rses` (the default case) would run on all RSEs anyway.

Finally, the main reaper/reaper2 do not have the `all_rses` option when selecting RSEs.

Modification
------------

Remove the option for `all_rses`. Make this a `feature` PR as it may affect existing instances. Make sure this change is compatible with VO handling for the reapers.


Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/reaper/dark_reaper.py b/lib/rucio/daemons/reaper/dark_reaper.py
--- a/lib/rucio/daemons/reaper/dark_reaper.py
+++ b/lib/rucio/daemons/reaper/dark_reaper.py
@@ -180,7 +180,7 @@ def stop(signum=None, frame=None):
     GRACEFUL_STOP.set()
 
 
-def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_rses=False,
+def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None,
         exclude_rses=None, include_rses=None, vos=None, delay_seconds=0):
     """
     Starts up the reaper threads.
@@ -202,11 +202,6 @@ def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_r
         if vos:
             logging.warning('Ignoring argument vos, this is only applicable in a multi-VO setup.')
         vos = ['def']
-
-        # Preserve the old behaviour until a feature release
-        all_rses = list_rses()
-        if all_rses:
-            rses = all_rses
     else:
         if vos:
             invalid = set(vos) - set([v['vo'] for v in list_vos()])
@@ -217,31 +212,31 @@ def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_r
             vos = [v['vo'] for v in list_vos()]
         logging.info('Dark Reaper: This instance will work on VO%s: %s' % ('s' if len(vos) > 1 else '', ', '.join([v for v in vos])))
 
-        all_rses = []
-        for vo in vos:
-            all_rses.extend(list_rses(filters={'vo': vo}))
-
-        if rses:
-            invalid = set(rses) - set([rse['rse'] for rse in all_rses])
-            if invalid:
-                msg = 'RSE{} {} cannot be found'.format('s' if len(invalid) > 1 else '',
-                                                        ', '.join([repr(rse) for rse in invalid]))
-                raise RSENotFound(msg)
-            rses = [rse for rse in all_rses if rse['rse'] in rses]
-        else:
-            rses = all_rses
+    all_rses = []
+    for vo in vos:
+        all_rses.extend(list_rses(filters={'vo': vo}))
+
+    if rses:
+        invalid = set(rses) - set([rse['rse'] for rse in all_rses])
+        if invalid:
+            msg = 'RSE{} {} cannot be found'.format('s' if len(invalid) > 1 else '',
+                                                    ', '.join([repr(rse) for rse in invalid]))
+            raise RSENotFound(msg)
+        rses = [rse for rse in all_rses if rse['rse'] in rses]
+    else:
+        rses = all_rses
 
-        if exclude_rses:
-            excluded_rses = parse_expression(exclude_rses)
-            rses = [rse for rse in rses if rse not in excluded_rses]
+    if exclude_rses:
+        excluded_rses = parse_expression(exclude_rses)
+        rses = [rse for rse in rses if rse not in excluded_rses]
 
-        if include_rses:
-            included_rses = parse_expression(include_rses)
-            rses = [rse for rse in rses if rse in included_rses]
+    if include_rses:
+        included_rses = parse_expression(include_rses)
+        rses = [rse for rse in rses if rse in included_rses]
 
-        if not rses:
-            logging.error('Dark Reaper: No RSEs found. Exiting.')
-            return
+    if not rses:
+        logging.error('Dark Reaper: No RSEs found. Exiting.')
+        return
 
     threads = []
     for worker in range(total_workers):
diff --git a/lib/rucio/daemons/reaper/light_reaper.py b/lib/rucio/daemons/reaper/light_reaper.py
--- a/lib/rucio/daemons/reaper/light_reaper.py
+++ b/lib/rucio/daemons/reaper/light_reaper.py
@@ -175,7 +175,7 @@ def stop(signum=None, frame=None):
     GRACEFUL_STOP.set()
 
 
-def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_rses=False,
+def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None,
         exclude_rses=None, include_rses=None, vos=None, delay_seconds=0):
     """
     Starts up the reaper threads.
@@ -197,11 +197,6 @@ def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_r
         if vos:
             logging.warning('Ignoring argument vos, this is only applicable in a multi-VO setup.')
         vos = ['def']
-
-        # Preserve the old behaviour until a feature release
-        all_rses = rse_core.list_rses()
-        if all_rses:
-            rses = all_rses
     else:
         if vos:
             invalid = set(vos) - set([v['vo'] for v in list_vos()])
@@ -212,32 +207,31 @@ def run(total_workers=1, chunk_size=100, once=False, rses=[], scheme=None, all_r
             vos = [v['vo'] for v in list_vos()]
         logging.info('Light Reaper: This instance will work on VO%s: %s' % ('s' if len(vos) > 1 else '', ', '.join([v for v in vos])))
 
-        # Only use the include/exclude RSE options for m-VO until a feature release
-        all_rses = []
-        for vo in vos:
-            all_rses.extend(rse_core.list_rses(filters={'vo': vo}))
-
-        if rses:
-            invalid = set(rses) - set([rse['rse'] for rse in all_rses])
-            if invalid:
-                msg = 'RSE{} {} cannot be found'.format('s' if len(invalid) > 1 else '',
-                                                        ', '.join([repr(rse) for rse in invalid]))
-                raise RSENotFound(msg)
-            rses = [rse for rse in all_rses if rse['rse'] in rses]
-        else:
-            rses = all_rses
+    all_rses = []
+    for vo in vos:
+        all_rses.extend(rse_core.list_rses(filters={'vo': vo}))
+
+    if rses:
+        invalid = set(rses) - set([rse['rse'] for rse in all_rses])
+        if invalid:
+            msg = 'RSE{} {} cannot be found'.format('s' if len(invalid) > 1 else '',
+                                                    ', '.join([repr(rse) for rse in invalid]))
+            raise RSENotFound(msg)
+        rses = [rse for rse in all_rses if rse['rse'] in rses]
+    else:
+        rses = all_rses
 
-        if exclude_rses:
-            excluded_rses = parse_expression(exclude_rses)
-            rses = [rse for rse in rses if rse not in excluded_rses]
+    if exclude_rses:
+        excluded_rses = parse_expression(exclude_rses)
+        rses = [rse for rse in rses if rse not in excluded_rses]
 
-        if include_rses:
-            included_rses = parse_expression(include_rses)
-            rses = [rse for rse in rses if rse in included_rses]
+    if include_rses:
+        included_rses = parse_expression(include_rses)
+        rses = [rse for rse in rses if rse in included_rses]
 
-        if not rses:
-            logging.error('Light Reaper: No RSEs found. Exiting.')
-            return
+    if not rses:
+        logging.error('Light Reaper: No RSEs found. Exiting.')
+        return
 
     threads = []
     for worker in range(total_workers):


Test patch: