]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: add default argument values to strategy
authorJan Fajerski <jfajerski@suse.com>
Mon, 7 Jan 2019 13:43:12 +0000 (14:43 +0100)
committerJan Fajerski <jfajerski@suse.com>
Fri, 19 Jul 2019 11:19:10 +0000 (13:19 +0200)
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
(cherry picked from commit 5465712e4d71315ff8daac9345be6ba96d1f44c4)

 Conflicts:
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py
        pick with_auto_devices and error.value changes

src/ceph-volume/ceph_volume/devices/lvm/batch.py
src/ceph-volume/ceph_volume/devices/lvm/strategies/bluestore.py
src/ceph-volume/ceph_volume/devices/lvm/strategies/filestore.py
src/ceph-volume/ceph_volume/devices/lvm/strategies/strategies.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py

index 2da6aab816615fcbd1020342726cc1dbdb519862..93cc5aa0bf058351bb0c402e47c00986e4e23887 100644 (file)
@@ -287,7 +287,7 @@ class Batch(object):
                 mlogger.error("Aborting because strategy changed from %s to %s after filtering" % (strategy.type(), new_strategy.type()))
                 raise SystemExit(1)
 
-        self.strategy = strategy.with_auto_devices(unused_devices, self.args)
+        self.strategy = strategy.with_auto_devices(self.args, unused_devices)
 
     @decorators.needs_root
     def main(self):
@@ -317,27 +317,23 @@ class Batch(object):
         if self.args.bluestore:
             if self.db_usable:
                 self.strategy = strategies.bluestore.MixedType(
+                    self.args,
                     self.usable,
-                    self.db_usable,
-                    [],
-                    self.args)
+                    self.db_usable)
             else:
                 self.strategy = strategies.bluestore.SingleType(
-                    self.usable,
-                    self.db_usable,
-                    [],
-                    self.args)
+                    self.args,
+                    self.usable)
         else:
             if self.journal_usable:
                 self.strategy = strategies.filestore.MixedType(
+                    self.args,
                     self.usable,
-                    self.journal_usable,
-                    self.args)
+                    self.journal_usable)
             else:
                 self.strategy = strategies.filestore.SingleType(
-                    self.usable,
-                    self.journal_usable,
-                    self.args)
+                    self.args,
+                    self.usable)
 
 
     def _filter_devices(self):
index 31ee230070fe8302448052cb6878bb873527155d..e5f63272bb75ca9b07fb46a39451bcb6a56446da 100644 (file)
@@ -15,14 +15,14 @@ class SingleType(Strategy):
     Support for all SSDs, or all HDDS
     """
 
-    def __init__(self, data_devs, args):
-        super(SingleType, self).__init__(data_devs, [], [], args)
+    def __init__(self, args, data_devs):
+        super(SingleType, self).__init__(args, data_devs)
         self.validate_compute()
 
     @classmethod
-    def with_auto_devices(cls, devices, args):
+    def with_auto_devices(cls, args, devices):
         #SingleType only deploys standalone OSDs
-        return cls(devices, args)
+        return cls(args, devices)
 
     @staticmethod
     def type():
@@ -117,8 +117,8 @@ class SingleType(Strategy):
 
 class MixedType(MixedStrategy):
 
-    def __init__(self, data_devs, db_devs, wal_devs, args):
-        super(MixedType, self).__init__(data_devs, db_devs, wal_devs, args)
+    def __init__(self, args, data_devs, db_devs, wal_devs=[]):
+        super(MixedType, self).__init__(args, data_devs, db_devs, wal_devs)
         self.block_db_size = self.get_block_size()
         self.system_vgs = lvm.VolumeGroups()
         self.dbs_needed = len(self.data_devs) * self.osds_per_device
@@ -126,9 +126,9 @@ class MixedType(MixedStrategy):
         self.validate_compute()
 
     @classmethod
-    def with_auto_devices(cls, devices, args):
+    def with_auto_devices(cls, args, devices):
         data_devs, db_devs = cls.split_devices_rotational(devices)
-        return cls(data_devs, db_devs, [], args)
+        return cls(args, data_devs, db_devs)
 
     @staticmethod
     def type():
index cf7763eb5e6c96ece2e899374fd12dd764fc5010..a20192a88217e885b22ccfb9b8a18e593f99dbc0 100644 (file)
@@ -28,14 +28,14 @@ class SingleType(Strategy):
     """
 
 
-    def __init__(self, data_devs, args):
-        super(SingleType, self).__init__(data_devs, [], [], args)
+    def __init__(self, args, data_devs):
+        super(SingleType, self).__init__(args, data_devs)
         self.journal_size = get_journal_size(args)
         self.validate_compute()
 
     @classmethod
-    def with_auto_devices(cls, devices, args):
-        return cls(devices, args)
+    def with_auto_devices(cls, args, devices):
+        return cls(args, devices)
 
     @staticmethod
     def type():
@@ -167,8 +167,8 @@ class MixedType(MixedStrategy):
     """
 
 
-    def __init__(self, data_devs, journal_devs, args):
-        super(MixedType, self).__init__(data_devs, journal_devs, [], args)
+    def __init__(self, args, data_devs, journal_devs):
+        super(MixedType, self).__init__(args, data_devs, journal_devs)
         self.blank_ssds = []
         self.journals_needed = len(self.data_devs) * self.osds_per_device
         self.journal_size = get_journal_size(args)
@@ -176,9 +176,9 @@ class MixedType(MixedStrategy):
         self.validate_compute()
 
     @classmethod
-    def with_auto_devices(cls, devices, args):
+    def with_auto_devices(cls, args, devices):
         data_devs, journal_devs = cls.split_devices_rotational(devices)
-        return cls(data_devs, journal_devs, args)
+        return cls(args, data_devs, journal_devs)
 
     @staticmethod
     def type():
index f8f1ca979d2d1824311b87de6691ed8bf51c8b98..5a9d52cf159b56e44a7a6bd9d172c66c8052acca 100644 (file)
@@ -2,7 +2,7 @@ import json
 
 class Strategy(object):
 
-    def __init__(self, data_devs, db_or_journal_devs, wal_devs, args):
+    def __init__(self, args, data_devs, db_or_journal_devs=[], wal_devs=[]):
         '''
         Note that this ctor is used by both bluestore and filestore strategies
         to reduce code duplication. A filestore strategy will always pass an
index dd3a877f217dab620a29a7e8969c96abc33975c0..72e936af43e434020a96e21d88291baf264eaef2 100644 (file)
@@ -9,7 +9,7 @@ class TestSingleType(object):
         devices = [
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
-        computed_osd = bluestore.SingleType(devices, args).computed['osds'][0]
+        computed_osd = bluestore.SingleType.with_auto_devices(args, devices).computed['osds'][0]
         assert computed_osd['data']['percentage'] == 100
         assert computed_osd['data']['parts'] == 1
         assert computed_osd['data']['human_readable_size'] == '5.66 GB'
@@ -20,7 +20,7 @@ class TestSingleType(object):
         devices = [
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000))
         ]
-        computed_osd = bluestore.SingleType(devices, args).computed['osds'][0]
+        computed_osd = bluestore.SingleType.with_auto_devices(args, devices).computed['osds'][0]
         assert computed_osd['data']['percentage'] == 100
         assert computed_osd['data']['parts'] == 1
         assert computed_osd['data']['human_readable_size'] == '5.66 GB'
@@ -32,7 +32,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            bluestore.SingleType(devices, args)
+            bluestore.SingleType.with_auto_devices(args, devices)
         assert 'Unable to use device 5.66 GB /dev/sda' in str(error.value)
 
     def test_device_is_lvm_member_fails(self, fakedevice, factory):
@@ -41,6 +41,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=True, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
+            bluestore.SingleType.with_auto_devices(args, devices)
             bluestore.SingleType(devices, args)
         assert 'Unable to use device, already a member of LVM' in str(error.value)
 
@@ -57,7 +58,7 @@ class TestMixedTypeConfiguredSize(object):
         hdd = fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         devices = [ssd, hdd]
 
-        osd = bluestore.MixedType(devices, args).computed['osds'][0]
+        osd = bluestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         assert osd['data']['percentage'] == 100
         assert osd['data']['human_readable_size'] == '5.66 GB'
         assert osd['data']['path'] == '/dev/sda'
@@ -74,7 +75,7 @@ class TestMixedTypeConfiguredSize(object):
         devices = [ssd, hdd]
 
         with pytest.raises(RuntimeError) as error:
-            bluestore.MixedType(devices, args).computed['osds'][0]
+            bluestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         expected = 'Not enough space in fast devices (5.66 GB) to create 1 x 7.22 GB block.db LV'
         assert expected in str(error.value)
 
@@ -87,7 +88,7 @@ class TestMixedTypeConfiguredSize(object):
         devices = [ssd, hdd]
 
         with pytest.raises(RuntimeError) as error:
-            bluestore.MixedType(devices, args)
+            bluestore.MixedType.with_auto_devices(args, devices)
         expected = 'Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB'
         assert expected in str(error.value)
 
@@ -101,7 +102,7 @@ class TestMixedTypeLargeAsPossible(object):
         hdd = fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         devices = [ssd, hdd]
 
-        osd = bluestore.MixedType(devices, args).computed['osds'][0]
+        osd = bluestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         assert osd['data']['percentage'] == 100
         assert osd['data']['human_readable_size'] == '5.66 GB'
         assert osd['data']['path'] == '/dev/sda'
@@ -117,7 +118,7 @@ class TestMixedTypeLargeAsPossible(object):
         hdd = fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=60073740000))
         devices = [ssd, hdd]
 
-        osd = bluestore.MixedType(devices, args).computed['osds'][0]
+        osd = bluestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         assert osd['data']['percentage'] == 50
         assert osd['data']['human_readable_size'] == '27.97 GB'
         assert osd['data']['path'] == '/dev/sda'
@@ -134,6 +135,6 @@ class TestMixedTypeLargeAsPossible(object):
         devices = [ssd, hdd]
 
         with pytest.raises(RuntimeError) as error:
-            bluestore.MixedType(devices, args)
+            bluestore.MixedType.with_auto_devices(args, devices)
         expected = 'Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB'
         assert expected in str(error.value)
index 5e9b661ffa7334bc89e74390eec4681655142969..35d9bbe609d3b35226e2ec3f239b3789410e0463 100644 (file)
@@ -11,7 +11,7 @@ class TestSingleType(object):
         devices = [
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=12073740000))
         ]
-        computed_osd = filestore.SingleType(devices, args).computed['osds'][0]
+        computed_osd = filestore.SingleType.with_auto_devices(args, devices).computed['osds'][0]
         assert computed_osd['data']['percentage'] == 55
         assert computed_osd['data']['parts'] == 1
         assert computed_osd['data']['human_readable_size'] == '6.24 GB'
@@ -24,7 +24,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
         assert msg in str(error.value)
 
@@ -34,7 +34,7 @@ class TestSingleType(object):
         devices = [
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='0', size=12073740000))
         ]
-        computed_osd = filestore.SingleType(devices, args).computed['osds'][0]
+        computed_osd = filestore.SingleType.with_auto_devices(args, devices).computed['osds'][0]
         assert computed_osd['data']['percentage'] == 55
         assert computed_osd['data']['parts'] == 1
         assert computed_osd['data']['human_readable_size'] == '6.24 GB'
@@ -47,7 +47,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
         assert msg in str(error.value)
 
@@ -58,7 +58,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='0', size=16073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
         assert msg in str(error.value)
 
@@ -69,7 +69,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=16073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
         assert msg in str(error.value)
 
@@ -80,7 +80,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=True, sys_api=dict(rotational='1', size=12073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         assert 'Unable to use device, already a member of LVM' in str(error.value)
 
     def test_hdd_device_with_small_configured_journal(self, fakedevice, factory, conf_ceph):
@@ -90,7 +90,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
         assert msg in str(error.value)
 
@@ -101,7 +101,7 @@ class TestSingleType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.SingleType(devices, args)
+            filestore.SingleType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
         assert msg in str(error.value)
 
@@ -116,7 +116,7 @@ class TestMixedType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.MixedType(devices, args)
+            filestore.MixedType.with_auto_devices(args, devices)
         msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
         assert msg in str(error.value)
 
@@ -128,7 +128,7 @@ class TestMixedType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.MixedType(devices, args)
+            filestore.MixedType.with_auto_devices(args, devices)
         msg = "Not enough space in fast devices (5.66 GB) to create 1 x 6.95 GB journal LV"
         assert msg in str(error.value)
 
@@ -140,7 +140,7 @@ class TestMixedType(object):
             fakedevice(used_by_ceph=False, is_lvm_member=True, sys_api=dict(rotational='1', size=6073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.MixedType(devices, args)
+            filestore.MixedType.with_auto_devices(args, devices)
         assert 'Unable to use device, already a member of LVM' in str(error.value)
 
     def test_ssd_is_lvm_member_doesnt_fail(self, volumes, stub_vgs, fakedevice, factory, conf_ceph):
@@ -161,7 +161,7 @@ class TestMixedType(object):
         conf_ceph(get_safe=lambda *a: '5120')
         args = factory(filtered_devices=[], osds_per_device=1, journal_size=None)
         devices = [ssd, hdd]
-        result = filestore.MixedType(devices, args).computed['osds'][0]
+        result = filestore.MixedType.with_auto_devices(args, devices).computed['osds'][0]
         assert result['journal']['path'] == 'vg: fast'
         assert result['journal']['percentage'] == 71
         assert result['journal']['human_readable_size'] == '5.00 GB'
@@ -193,7 +193,7 @@ class TestMixedType(object):
         args = factory(filtered_devices=[], osds_per_device=1, journal_size=None)
         devices = [ssd1, ssd2, hdd]
         with pytest.raises(RuntimeError) as error:
-            filestore.MixedType(devices, args)
+            filestore.MixedType.with_auto_devices(args, devices)
 
         assert 'Could not find a common VG between devices' in str(error.value)
 
@@ -205,6 +205,6 @@ class TestMixedType(object):
             fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=16073740000))
         ]
         with pytest.raises(RuntimeError) as error:
-            filestore.MixedType(devices, args)
+            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)