]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/ceph_manager: population must be a sequence
authorKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Fri, 18 Apr 2025 10:57:57 +0000 (12:57 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@clyso.com>
Fri, 18 Apr 2025 12:09:26 +0000 (14:09 +0200)
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>
qa/tasks/ceph_manager.py

index 57d22f3b5e637cc45551ae39585185ddef45076e..de86b188f556f29ea428d174130f8fd29ae443a6 100644 (file)
@@ -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):
         """