From: Sage Weil Date: Wed, 10 Jul 2019 16:04:49 +0000 (-0500) Subject: qa/tasks/ceph_manager: make is_{clean,recovered,active_or_down} less racy X-Git-Tag: v15.1.0~2234^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0b4ce2ab4c19e4c2233df13bdcdb1152a6dc24ea;p=ceph-ci.git qa/tasks/ceph_manager: make is_{clean,recovered,active_or_down} less racy Currently these can be thrown off if the cluster is creating or removing pools at the same time. Fix by taking a single snapshot of the pg stats and based our judgement on that. Signed-off-by: Sage Weil --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index a127c2b3fe0..25858bf8c02 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -2147,6 +2147,9 @@ class CephManager: Find the number of active and clean pgs. """ pgs = self.get_pg_stats() + return self._get_num_active_clean(pgs) + + def _get_num_active_clean(self, pgs): num = 0 for pg in pgs: if (pg['state'].count('active') and @@ -2160,6 +2163,9 @@ class CephManager: Find the number of active and recovered pgs. """ pgs = self.get_pg_stats() + return self._get_num_active_recovered(pgs) + + def _get_num_active_recovered(self, pgs): num = 0 for pg in pgs: if (pg['state'].count('active') and @@ -2210,6 +2216,9 @@ class CephManager: Find the number of pgs that are either active or down. """ pgs = self.get_pg_stats() + return self._get_num_active_down(pgs) + + def _get_num_active_down(self, pgs): num = 0 for pg in pgs: if ((pg['state'].count('active') and not @@ -2236,19 +2245,22 @@ class CephManager: """ True if all pgs are clean """ - return self.get_num_active_clean() == self.get_num_pgs() + pgs = self.get_pg_stats() + return self._get_num_active_clean(pgs) == len(pgs) def is_recovered(self): """ True if all pgs have recovered """ - return self.get_num_active_recovered() == self.get_num_pgs() + pgs = self.get_pg_stats() + return self._get_num_active_recovered(pgs) == len(pgs) def is_active_or_down(self): """ True if all pgs are active or down """ - return self.get_num_active_down() == self.get_num_pgs() + pgs = self.get_pg_stats() + return self._get_num_active_down(pgs) == len(pgs) def wait_for_clean(self, timeout=1200): """