]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-volume: don't keep device lists as sets
authorJan Fajerski <jfajerski@suse.com>
Thu, 15 Aug 2019 10:20:00 +0000 (12:20 +0200)
committerJan Fajerski <jfajerski@suse.com>
Thu, 15 Aug 2019 13:31:03 +0000 (15:31 +0200)
This was introduced by #27754. The explicit device lists were cast to
sets but other parts of the code where not updated accordingly. To avoid
touching all code places, only cast to sets for disjoint test and keep
lists otherwise.

Fixes: https://tracker.ceph.com/issues/41292
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/ceph-volume/ceph_volume/devices/lvm/batch.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_batch.py

index 223aa4ac99ccb337d8b04b4929ea2364dce27d45..8685f588c61e0c5ca217d09c47c4b99ed4aa847d 100644 (file)
@@ -254,7 +254,7 @@ class Batch(object):
         self.args = parser.parse_args(argv)
         self.parser = parser
         for dev_list in ['', 'db_', 'wal_', 'journal_']:
-            setattr(self, '{}usable'.format(dev_list), set())
+            setattr(self, '{}usable'.format(dev_list), [])
 
     def get_devices(self):
         # remove devices with partitions
@@ -361,8 +361,8 @@ class Batch(object):
             dev_list_prop = '{}devices'.format(dev_list)
             if hasattr(self.args, dev_list_prop):
                 usable_dev_list_prop = '{}usable'.format(dev_list)
-                usable = set([d for d in getattr(self.args, dev_list_prop) if
-                              d.available])
+                usable = [d for d in getattr(self.args, dev_list_prop) if
+                          d.available]
                 setattr(self, usable_dev_list_prop, usable)
                 self.filtered_devices.update({d: used_reason for d in
                                               getattr(self.args, dev_list_prop)
@@ -370,8 +370,8 @@ class Batch(object):
 
     def _ensure_disjoint_device_lists(self):
         # check that all device lists are disjoint with each other
-        if not(self.usable.isdisjoint(self.db_usable) and
-               self.usable.isdisjoint(self.wal_usable) and
-               self.usable.isdisjoint(self.journal_usable) and
-               self.db_usable.isdisjoint(self.wal_usable)):
+        if not(set(self.usable).isdisjoint(set(self.db_usable)) and
+               set(self.usable).isdisjoint(set(self.wal_usable)) and
+               set(self.usable).isdisjoint(set(self.journal_usable)) and
+               set(self.db_usable).isdisjoint(set(self.wal_usable))):
             raise Exception('Device lists are not disjoint')
index 9fb814950960392ea58ca31d48cfb2de629027fc..bc9afb7068192651e4f318074094c2d9cd940724 100644 (file)
@@ -223,12 +223,3 @@ class TestMixedType(object):
             filestore.MixedType.with_auto_devices(args, devices)
         msg = "Not enough space in fast devices (14.97 GB) to create 2 x 14.77 GB journal LV"
         assert msg in str(error.value)
-
-    def test_filter_all_data_devs(self, fakedevice, factory):
-        # in this scenario the user passed a already used device to be used for
-        # data and an unused device to be used as db device.
-        db_dev = fakedevice(used_by_ceph=False, is_lvm_member=False, rotational=False, sys_api=dict(size=6073740000))
-        data_dev = fakedevice(used_by_ceph=True, is_lvm_member=False, rotational=True, sys_api=dict(size=6073740000))
-        args = factory(filtered_devices=[data_dev], osds_per_device=1,
-                       journal_size=None, osd_ids=[])
-        filestore.MixedType(args, [], [db_dev])
index f03110289844e9ab6281f740f7a5d7c8c8eb4c55..c6b3f3b6d4dfea31a704b233296e4d76057ff530 100644 (file)
@@ -63,8 +63,9 @@ class TestBatch(object):
         b.args.devices = [device1, device2]
         b.args.db_devices = [device2]
         b._filter_devices()
-        with pytest.raises(Exception):
+        with pytest.raises(Exception) as disjoint_ex:
             b._ensure_disjoint_device_lists()
+        assert 'Device lists are not disjoint' in str(disjoint_ex.value)
 
 
 class TestFilterDevices(object):