]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
thrashers: standardize stop and join method names 58282/head
authorNitzan Mordechai <nmordech@redhat.com>
Tue, 2 Jul 2024 08:31:38 +0000 (08:31 +0000)
committerNitzan Mordechai <nmordech@redhat.com>
Tue, 6 Aug 2024 06:57:40 +0000 (06:57 +0000)
Thrashers that do not inherit from ThrasherGreenlet previously used a
method called do_join, which combined stop and join functionality. To
ensure consistency and clarity, we want all thrashers to use separate
stop, join, and stop_and_join methods.

This commit renames methods and implements missing stop and stop_and_join
methods in thrashers that did not inherit from ThrasherGreenlet.

Fixes: https://tracker.ceph.com/issues/66698
Signed-off-by: Nitzan Mordechai <nmordech@redhat.com>
qa/tasks/ceph_manager.py
qa/tasks/mon_thrash.py
qa/tasks/scrub.py
qa/tasks/thrasher.py
qa/tasks/thrashosds.py

index af68381829716503508e61f8a3f00cf566ae52df..3416703fef3a8ed7986da7778bbdc2e684cea1be 100644 (file)
@@ -870,11 +870,16 @@ class OSDThrasher(Thrasher):
             self.ceph_manager.raw_cluster_cmd('osd', 'primary-affinity',
                                               str(osd), str(1))
 
-    def do_join(self):
+    def stop(self):
         """
-        Break out of this Ceph loop
+        Stop the thrasher
         """
         self.stopping = True
+
+    def join(self):
+        """
+        Break out of this Ceph loop
+        """
         self.thread.get()
         if self.sighup_delay:
             self.log("joining the do_sighup greenlet")
@@ -889,6 +894,13 @@ class OSDThrasher(Thrasher):
             self.log("joining the do_noscrub_toggle greenlet")
             self.noscrub_toggle_thread.join()
 
+    def stop_and_join(self):
+        """
+        Stop and join the thrasher
+        """
+        self.stop()
+        return self.join()
+
     def grow_pool(self):
         """
         Increase the size of the pool
index d2bcaf3f087985d7e5cd7e714cc35cce88151619..34aa1f9cc9e2495408fbe46a029238236d483820 100644 (file)
@@ -157,13 +157,26 @@ class MonitorThrasher(Thrasher):
         """
         self.logger.info(x)
 
-    def do_join(self):
+    def stop(self):
+        """
+        Stop the thrashing process.
+        """
+        self.stopping = True
+
+    def join(self):
         """
         Break out of this processes thrashing loop.
         """
         self.stopping.set()
         self.thread.get()
 
+    def stop_and_join(self):
+        """
+        Stop the thrashing process and join the thread.
+        """
+        self.stop()
+        return self.join()
+
     def should_thrash_store(self):
         """
         If allowed, indicate that we should thrash a certain percentage of
@@ -450,6 +463,6 @@ def task(ctx, config):
         yield
     finally:
         log.info('joining mon_thrasher')
-        thrash_proc.do_join()
+        thrash_proc.stop_and_join()
         mons = _get_mons(ctx)
         manager.wait_for_mon_quorum_size(len(mons))
index ddc1a9164cfc825cd5ba9e35cc4c1eb088baadac..74a2fcd2b2020ad04806df4fdae3974a171c4716 100644 (file)
@@ -59,7 +59,7 @@ def task(ctx, config):
         yield
     finally:
         log.info('joining scrub')
-        scrub_proc.do_join()
+        scrub_proc.stop_and_join()
 
 class Scrubber:
     """
@@ -91,11 +91,19 @@ class Scrubber:
 
         self.thread = gevent.spawn(self.do_scrub)
 
-    def do_join(self):
-        """Scrubbing thread finished"""
+    def stop(self):
+        """Stop scrubbing"""
         self.stopping = True
+
+    def join(self):
+        """Scrubbing thread finished"""
         self.thread.get()
 
+    def stop_and_join(self):
+        """Stop scrubbing thread"""
+        self.stop()
+        return self.join()
+
     def do_scrub(self):
         """Perform the scrub operation"""
         frequency = self.config.get("frequency", 30)
index e8fc14e404891560f4eb87c615f0fa07bdb49440..d8a0509d54cc2ce9e65f9fc97fdccb37d654a776 100644 (file)
@@ -19,6 +19,9 @@ class Thrasher(object):
     def set_thrasher_exception(self, e):
         self._exception = e
 
+    def stop(self):
+        raise NotImplementedError("Subclasses didn't implement this method.")
+
 class ThrasherGreenlet(Thrasher, Greenlet):
 
     class Stopped(Exception): ...
@@ -46,3 +49,7 @@ class ThrasherGreenlet(Thrasher, Greenlet):
         if self.is_stopped and raise_stopped:
             raise self.Stopped()
         return not self.is_stopped
+
+    def stop_and_join(self):
+        self.stop()
+        return self.join()
index 476e0e4755a75cc2c6401234f7c2056afe8bcfbd..1b3e65b266a872ad46f0c3271f986bfb7b60a417 100644 (file)
@@ -214,7 +214,7 @@ def task(ctx, config):
         yield
     finally:
         log.info('joining thrashosds')
-        thrash_proc.do_join()
+        thrash_proc.stop_and_join()
         cluster_manager.wait_for_all_osds_up()
         cluster_manager.flush_all_pg_stats()
         cluster_manager.wait_for_recovery(config.get('timeout', 360))