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 <kyrylo.shatskyy@clyso.com>
"""
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):
"""