Skip to content

Commit ce4a783

Browse files
author
Kyr Shatskyy
committed
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 <[email protected]>
1 parent 4e368a9 commit ce4a783

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

qa/tasks/ceph_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ def get_pool(self):
22982298
"""
22992299
with self.lock:
23002300
if self.pools:
2301-
return random.sample(self.pools.keys(), 1)[0]
2301+
return random.sample(list(self.pools.keys()), 1)[0]
23022302

23032303
def get_pool_pg_num(self, pool_name):
23042304
"""

0 commit comments

Comments
 (0)