From: Kyr Shatskyy Date: Fri, 18 Apr 2025 10:57:57 +0000 (+0200) Subject: qa/tasks/ceph_manager: population must be a sequence X-Git-Tag: testing/wip-vshankar-testing-20250613.134551-debug~15^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ce4a7831ea41b3400ad1b8e92eab85b0f17d720b;p=ceph-ci.git qa/tasks/ceph_manager: population must be a sequence This patch addresses TypeError message for rados_bench if there is python3.11 for example. 2025-04-17T17:05:45.719 INFO:tasks.thrashosds.thrasher:Traceback (most recent call last): File "/home/debian/src/github.com_kshtsk_ceph_b8b19a59890781db2f405500155c975cbdeb38a1/qa/tasks/ceph_manager.py", line 192, in wrapper return func(self) ^^^^^^^^^^ File "/home/debian/src/github.com_kshtsk_ceph_b8b19a59890781db2f405500155c975cbdeb38a1/qa/tasks/ceph_manager.py", line 1439, in _do_thrash self.choose_action()() File "/home/debian/src/github.com_kshtsk_ceph_b8b19a59890781db2f405500155c975cbdeb38a1/qa/tasks/ceph_manager.py", line 855, in grow_pool pool = self.ceph_manager.get_pool() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/debian/src/github.com_kshtsk_ceph_b8b19a59890781db2f405500155c975cbdeb38a1/qa/tasks/ceph_manager.py", line 2221, in get_pool return random.sample(self.pools.keys(), 1)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/random.py", line 439, in sample raise TypeError("Population must be a sequence. " TypeError: Population must be a sequence. For dicts or sets, use sorted(d). This happens because dict.keys() returns dict_keys() instead of list, however the random.sample() accepts a list only as first argument because sampling from a set deprecated since Python 3.9 and eventually removed since 3.11 version. Signed-off-by: Kyr Shatskyy --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 57d22f3b5e6..de86b188f55 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -2298,7 +2298,7 @@ class CephManager: """ with self.lock: if self.pools: - return random.sample(self.pools.keys(), 1)[0] + return random.sample(list(self.pools.keys()), 1)[0] def get_pool_pg_num(self, pool_name): """