]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/ceph_manager: do not pick a pool is there is no pools 32519/head
authorKefu Chai <kchai@redhat.com>
Tue, 7 Jan 2020 08:15:51 +0000 (16:15 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 9 Jan 2020 02:26:32 +0000 (10:26 +0800)
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 <kchai@redhat.com>
qa/tasks/ceph_manager.py

index fb3e1b21142c62338d19cb7b4dce1d9dc71461f1..bc025b33b6920ce788aa6fffe48dcc1fc18a7ff8 100644 (file)
@@ -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):
         """