From e67034b95a35add477025214ed6418fd5320a915 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 7 Jan 2020 16:15:51 +0800 Subject: [PATCH] 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 --- qa/tasks/ceph_manager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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): """ -- 2.47.3