Repository: rucio/rucio

Issue:
Rename reaper2 to reaper




Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/reaper/reaper2.py b/lib/rucio/daemons/reaper/reaper.py
similarity index 99%
rename from lib/rucio/daemons/reaper/reaper2.py
rename to lib/rucio/daemons/reaper/reaper.py
--- a/lib/rucio/daemons/reaper/reaper2.py
+++ b/lib/rucio/daemons/reaper/reaper.py
@@ -396,12 +396,12 @@ def reaper(rses, include_rses, exclude_rses, vos=None, chunk_size=100, once=Fals
     :param auto_exclude_timeout:   Timeout for temporarily excluded RSEs.
     """
     hostname = socket.getfqdn()
-    executable = 'reaper2'
+    executable = 'reaper'
     pid = os.getpid()
     hb_thread = threading.current_thread()
     sanity_check(executable=executable, hostname=hostname)
     heart_beat = live(executable, hostname, pid, hb_thread)
-    prepend_str = 'reaper2[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
+    prepend_str = 'reaper[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
     logger = formatted_logger(logging.log, prepend_str + '%s')
 
     logger(logging.INFO, 'Reaper starting')
@@ -409,7 +409,7 @@ def reaper(rses, include_rses, exclude_rses, vos=None, chunk_size=100, once=Fals
     if not once:
         GRACEFUL_STOP.wait(10)  # To prevent running on the same partition if all the reapers restart at the same time
     heart_beat = live(executable, hostname, pid, hb_thread)
-    prepend_str = 'reaper2[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
+    prepend_str = 'reaper[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
     logger = formatted_logger(logging.log, prepend_str + '%s')
     logger(logging.INFO, 'Reaper started')
 
@@ -460,7 +460,7 @@ def reaper(rses, include_rses, exclude_rses, vos=None, chunk_size=100, once=Fals
             staging_areas = []
             dict_rses = {}
             heart_beat = live(executable, hostname, pid, hb_thread, older_than=3600)
-            prepend_str = 'reaper2[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
+            prepend_str = 'reaper[%i/%i] ' % (heart_beat['assign_thread'], heart_beat['nr_threads'])
             logger = formatted_logger(logging.log, prepend_str + '%s')
             tot_needed_free_space = 0
             for rse in rses_to_process:


Test patch:
diff --git a/lib/rucio/tests/test_abacus_account.py b/lib/rucio/tests/test_abacus_account.py
--- a/lib/rucio/tests/test_abacus_account.py
+++ b/lib/rucio/tests/test_abacus_account.py
@@ -38,7 +38,7 @@
 from rucio.core.rse import get_rse_id
 from rucio.daemons.abacus import account
 from rucio.daemons.judge import cleaner
-from rucio.daemons.reaper import reaper2
+from rucio.daemons.reaper import reaper
 from rucio.daemons.undertaker import undertaker
 from rucio.db.sqla import models
 from rucio.db.sqla.session import get_session
@@ -69,9 +69,9 @@ def tearDownClass(cls):
         undertaker.run(once=True)
         cleaner.run(once=True)
         if cls.vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=cls.rse, greedy=True)
+            reaper.run(once=True, include_rses=cls.rse, greedy=True)
 
     def test_abacus_account(self):
         """ ABACUS (ACCOUNT): Test update of account usage """
diff --git a/lib/rucio/tests/test_abacus_collection_replica.py b/lib/rucio/tests/test_abacus_collection_replica.py
--- a/lib/rucio/tests/test_abacus_collection_replica.py
+++ b/lib/rucio/tests/test_abacus_collection_replica.py
@@ -39,7 +39,7 @@
 from rucio.core.rse import get_rse_id, add_rse
 from rucio.daemons.abacus import collection_replica
 from rucio.daemons.judge import cleaner
-from rucio.daemons.reaper import reaper2
+from rucio.daemons.reaper import reaper
 from rucio.daemons.undertaker import undertaker
 from rucio.db.sqla import models, session
 from rucio.db.sqla.constants import DIDType, ReplicaState
@@ -73,9 +73,9 @@ def tearDownClass(cls):
         undertaker.run(once=True)
         cleaner.run(once=True)
         if cls.vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=cls.rse, greedy=True)
+            reaper.run(once=True, include_rses=cls.rse, greedy=True)
 
     def test_abacus_collection_replica_cleanup(self):
         """ ABACUS (COLLECTION REPLICA): Test if the cleanup procedure works correctly. """
@@ -143,13 +143,13 @@ def test_abacus_collection_replica(self):
         assert str(dataset_replica['state']) == 'UNAVAILABLE'
 
         # Delete all files -> collection replica should be deleted
-        from rucio.daemons.reaper.reaper2 import REGION
+        from rucio.daemons.reaper.reaper import REGION
         REGION.invalidate()
         cleaner.run(once=True)
         if self.vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], self.rse), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], self.rse), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=self.rse, greedy=True)
+            reaper.run(once=True, include_rses=self.rse, greedy=True)
         self.rule_client.add_replication_rule([{'scope': self.scope, 'name': self.dataset}], 1, self.rse, lifetime=-1)
         collection_replica.run(once=True)
         dataset_replica = [replica for replica in self.replica_client.list_dataset_replicas(self.scope, self.dataset)]
diff --git a/lib/rucio/tests/test_abacus_rse.py b/lib/rucio/tests/test_abacus_rse.py
--- a/lib/rucio/tests/test_abacus_rse.py
+++ b/lib/rucio/tests/test_abacus_rse.py
@@ -32,7 +32,7 @@
 from rucio.core.rse import get_rse_id, get_rse_usage
 from rucio.daemons.abacus import rse
 from rucio.daemons.judge import cleaner
-from rucio.daemons.reaper import reaper2
+from rucio.daemons.reaper import reaper
 from rucio.daemons.undertaker import undertaker
 from rucio.db.sqla import models
 from rucio.db.sqla.session import get_session
@@ -62,9 +62,9 @@ def tearDownClass(cls):
         undertaker.run(once=True)
         cleaner.run(once=True)
         if cls.vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (cls.vo['vo'], cls.rse), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=cls.rse, greedy=True)
+            reaper.run(once=True, include_rses=cls.rse, greedy=True)
 
     def test_abacus_rse(self):
         """ ABACUS (RSE): Test update of RSE usage. """
@@ -86,13 +86,13 @@ def test_abacus_rse(self):
         assert len(rse_usage_from_unavailable) == 0
 
         # Delete files -> rse usage should decrease
-        from rucio.daemons.reaper.reaper2 import REGION
+        from rucio.daemons.reaper.reaper import REGION
         REGION.invalidate()
         cleaner.run(once=True)
         if self.vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], self.rse), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], self.rse), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=self.rse, greedy=True)
+            reaper.run(once=True, include_rses=self.rse, greedy=True)
         rse.run(once=True)
         rse_usage = get_rse_usage(rse_id=self.rse_id)[0]
         assert rse_usage['used'] == 0
diff --git a/lib/rucio/tests/test_api_external_representation.py b/lib/rucio/tests/test_api_external_representation.py
--- a/lib/rucio/tests/test_api_external_representation.py
+++ b/lib/rucio/tests/test_api_external_representation.py
@@ -48,7 +48,7 @@
 from rucio.core.vo import add_vo, vo_exists
 from rucio.daemons.abacus import rse as abacus_rse
 from rucio.daemons.judge import cleaner
-from rucio.daemons.reaper import reaper2
+from rucio.daemons.reaper import reaper
 from rucio.db.sqla import constants
 from rucio.tests.common import rse_name_generator
 
@@ -372,9 +372,9 @@ def test_api_rse(self):
         # clean up files
         cleaner.run(once=True)
         if self.multi_vo:
-            reaper2.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], rse_mock), greedy=True)
+            reaper.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], rse_mock), greedy=True)
         else:
-            reaper2.run(once=True, include_rses=rse_mock, greedy=True)
+            reaper.run(once=True, include_rses=rse_mock, greedy=True)
         abacus_rse.run(once=True)
 
         out = api_rse.parse_rse_expression('%s|%s' % (self.rse_name, self.rse2_name), **self.vo)
diff --git a/lib/rucio/tests/test_conveyor.py b/lib/rucio/tests/test_conveyor.py
--- a/lib/rucio/tests/test_conveyor.py
+++ b/lib/rucio/tests/test_conveyor.py
@@ -19,7 +19,7 @@
 
 import pytest
 
-import rucio.daemons.reaper.reaper2
+import rucio.daemons.reaper.reaper
 from rucio.core import replica as replica_core
 from rucio.core import request as request_core
 from rucio.core import rse as rse_core
@@ -27,7 +27,7 @@
 from rucio.daemons.conveyor.finisher import finisher
 from rucio.daemons.conveyor.poller import poller
 from rucio.daemons.conveyor.submitter import submitter
-from rucio.daemons.reaper.reaper2 import reaper
+from rucio.daemons.reaper.reaper import reaper
 from rucio.db.sqla import models
 from rucio.db.sqla.constants import RequestState, ReplicaState
 from rucio.db.sqla.session import transactional_session
@@ -58,7 +58,7 @@ def __wait_for_replica_transfer(dst_rse_id, scope, name, max_wait_seconds=10):
 @pytest.mark.parametrize("caches_mock", [{"caches_to_mock": [
     'rucio.core.rse_expression_parser',  # The list of multihop RSEs is retrieved by rse expression
     'rucio.core.config',
-    'rucio.daemons.reaper.reaper2',
+    'rucio.daemons.reaper.reaper',
 ]}], indirect=True)
 def test_multihop_intermediate_replica_lifecycle(vo, did_factory, root_account, core_config_mock, caches_mock):
     """
@@ -99,7 +99,7 @@ def test_multihop_intermediate_replica_lifecycle(vo, did_factory, root_account,
         assert replica['state'] == ReplicaState.COPYING
 
         # The intermediate replica is protected by its state (Copying)
-        rucio.daemons.reaper.reaper2.REGION.invalidate()
+        rucio.daemons.reaper.reaper.REGION.invalidate()
         reaper(once=True, rses=[], include_rses=jump_rse_name, exclude_rses=None)
         replica = replica_core.get_replica(rse_id=jump_rse_id, **did)
         assert replica['state'] == ReplicaState.COPYING
@@ -112,7 +112,7 @@ def test_multihop_intermediate_replica_lifecycle(vo, did_factory, root_account,
         # Reaper must not remove this replica, even if it has an obsolete tombstone
         #
         # TODO: Uncomment following lines
-        # rucio.daemons.reaper.reaper2.REGION.invalidate()
+        # rucio.daemons.reaper.reaper.REGION.invalidate()
         # reaper(once=True, rses=[], include_rses=jump_rse_name, exclude_rses=None)
         # replica = replica_core.get_replica(rse_id=jump_rse_id, **did)
         # assert replica
@@ -124,7 +124,7 @@ def test_multihop_intermediate_replica_lifecycle(vo, did_factory, root_account,
         replica = __wait_for_replica_transfer(dst_rse_id=dst_rse_id, **did)
         assert replica['state'] == ReplicaState.AVAILABLE
 
-        rucio.daemons.reaper.reaper2.REGION.invalidate()
+        rucio.daemons.reaper.reaper.REGION.invalidate()
         reaper(once=True, rses=[], include_rses='test_container_xrd=True', exclude_rses=None)
 
         # TODO: reaper must delete this replica. It is not a source anymore.
diff --git a/lib/rucio/tests/test_daemons.py b/lib/rucio/tests/test_daemons.py
--- a/lib/rucio/tests/test_daemons.py
+++ b/lib/rucio/tests/test_daemons.py
@@ -34,7 +34,7 @@
 from rucio.daemons.hermes import hermes, hermes2
 from rucio.daemons.judge import cleaner, evaluator, injector, repairer
 from rucio.daemons.oauthmanager import oauthmanager
-from rucio.daemons.reaper import dark_reaper, light_reaper, reaper2
+from rucio.daemons.reaper import dark_reaper, light_reaper, reaper
 from rucio.daemons.replicarecoverer import suspicious_replica_recoverer
 from rucio.daemons.sonar.distribution import distribution_daemon
 from rucio.daemons.tracer import kronos
@@ -77,7 +77,7 @@
     oauthmanager,
     dark_reaper,
     light_reaper,
-    reaper2,
+    reaper,
     suspicious_replica_recoverer,
     distribution_daemon,
     # sonar_v3_dev_daemon,  -- lib/rucio/common/config.py:55: NoSectionError: No section: 'sonar'
diff --git a/lib/rucio/tests/test_reaper2.py b/lib/rucio/tests/test_reaper.py
similarity index 98%
rename from lib/rucio/tests/test_reaper2.py
rename to lib/rucio/tests/test_reaper.py
--- a/lib/rucio/tests/test_reaper2.py
+++ b/lib/rucio/tests/test_reaper.py
@@ -36,8 +36,8 @@
 from rucio.core import rule as rule_core
 from rucio.core import scope as scope_core
 from rucio.core import vo as vo_core
-from rucio.daemons.reaper.reaper2 import reaper, REGION
-from rucio.daemons.reaper.reaper2 import run as run_reaper
+from rucio.daemons.reaper.reaper import reaper, REGION
+from rucio.daemons.reaper.reaper import run as run_reaper
 from rucio.db.sqla.models import ConstituentAssociationHistory
 from rucio.db.sqla.session import read_session
 from rucio.tests.common import rse_name_generator
@@ -95,7 +95,7 @@ def __setup_scopes_for_vos(*vos):
 
 @pytest.mark.noparallel(reason='fails when run in parallel. It resets some memcached values.')
 def test_reaper(vo):
-    """ REAPER2 (DAEMON): Test the reaper2 daemon."""
+    """ REAPER (DAEMON): Test the reaper daemon."""
     scope = InternalScope('data13_hip', vo=vo)
 
     nb_files = 250
@@ -186,7 +186,7 @@ def test_reaper_affect_other_vo_via_run(vo):
 
 @pytest.mark.noparallel(reason='fails when run in parallel. It resets some memcached values.')
 def test_reaper_multi_vo(vo):
-    """ REAPER2 (DAEMON): Test the reaper2 daemon with multiple vo."""
+    """ REAPER (DAEMON): Test the reaper daemon with multiple vo."""
     new_vo = __setup_new_vo()
     _, [scope_tst, scope_new] = __setup_scopes_for_vos(vo, new_vo)