From: Kefu Chai Date: Tue, 7 Jan 2020 08:15:51 +0000 (+0800) Subject: qa/tasks/ceph_manager: do not pick a pool is there is no pools X-Git-Tag: v15.1.0~270^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F32519%2Fhead;p=ceph.git qa/tasks/ceph_manager: do not pick a pool is there is no pools random.choice(seq) raises IndexError if seq is empty. we cannot ensure there is always one or more pools in the cluster while using pool related thrasher. so skip the thrasher action if there is no pools at that moment. Fixes: https://tracker.ceph.com/issues/43412 Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index fb3e1b21142c..bc025b33b692 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -666,6 +666,8 @@ class OSDThrasher(Thrasher): Increase the size of the pool """ pool = self.ceph_manager.get_pool() + if pool is None: + return self.log("Growing pool %s" % (pool,)) if self.ceph_manager.expand_pool(pool, self.config.get('pool_grow_by', 10), @@ -677,6 +679,8 @@ class OSDThrasher(Thrasher): Decrease the size of the pool """ pool = self.ceph_manager.get_pool() + if pool is None: + return _ = self.ceph_manager.get_pool_pg_num(pool) self.log("Shrinking pool %s" % (pool,)) if self.ceph_manager.contract_pool( @@ -1877,7 +1881,8 @@ class CephManager: Pick a random pool """ with self.lock: - return random.choice(self.pools.keys()) + if self.pools: + return random.choice(self.pools.keys()) def get_pool_pg_num(self, pool_name): """