]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: fix strategy comparison in 'lvm batch'
authorAndrew Schoen <aschoen@redhat.com>
Thu, 4 Oct 2018 16:54:06 +0000 (11:54 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Mon, 15 Oct 2018 16:56:44 +0000 (11:56 -0500)
This also fixes some small json reporting issues with the
filestore MixedType strategy

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
(cherry picked from commit 1dd15025bfd52af9c31cd281f92d743b9ca0eeb8)

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

index 84580a562538e060a902cb802c6c3d2ae27dc52b..113c40149ceee39127fd7b0a33686c7ff1dae4de 100644 (file)
@@ -167,12 +167,12 @@ class Batch(object):
             raise SystemExit(0)
         else:
             new_strategy = get_strategy(args, unused_devices)
-            if type(strategy) != type(new_strategy):
-                if not args.report:
-                    mlogger.error("aborting because strategy changed from %s to %s after filtering" % (strategy, new_strategy))
-                    raise SystemExit(1)
-            else:
-                strategy = new_strategy
+            if strategy != new_strategy:
+                if args.report:
+                    mlogger.info("Ignoring devices already used by ceph: %s" % ",".join(used_devices))
+                mlogger.error("aborting because strategy changed from %s to %s after filtering" % (strategy.type(), new_strategy.type()))
+                raise SystemExit(1)
+
         return strategy(unused_devices, args)
 
     @decorators.needs_root
index 2cf401ec5c023c52ae1ce3cc34eaf5c7da27727d..1bdb713dd53f056d9dc8c91fe440f51dcf59e5d6 100644 (file)
@@ -24,6 +24,10 @@ class SingleType(object):
         self.validate()
         self.compute()
 
+    @staticmethod
+    def type():
+        return "filestore.MixedType"
+
     @property
     def total_osds(self):
         if self.hdds:
@@ -144,6 +148,10 @@ class MixedType(object):
         self.validate()
         self.compute()
 
+    @staticmethod
+    def type():
+        return "bluestore.MixedType"
+
     def report_json(self):
         print(json.dumps(self.computed, indent=4, sort_keys=True))
 
index 8751150aeb83ffdaa27222ba6412a2ee9358b7c6..72a379a6b24fd350419aa0fde60034c4733c2660 100644 (file)
@@ -36,6 +36,10 @@ class SingleType(object):
         self.validate()
         self.compute()
 
+    @staticmethod
+    def type():
+        return "filestore.SingleType"
+
     @property
     def total_osds(self):
         if self.hdds:
@@ -186,6 +190,10 @@ class MixedType(object):
         self.validate()
         self.compute()
 
+    @staticmethod
+    def type():
+        return "filestore.MixedType"
+
     def report_json(self):
         print(json.dumps(self.computed, indent=4, sort_keys=True))
 
@@ -304,11 +312,11 @@ class MixedType(object):
             # there isn't a common vg, so a new one must be created with all
             # the blank SSDs
             self.computed['vg'] = {
-                'devices': self.blank_ssds,
+                'devices': ", ".join([ssd.abspath for ssd in self.blank_ssds]),
                 'parts': self.journals_needed,
                 'percentages': self.vg_extents['percentages'],
-                'sizes': self.journal_size.b,
-                'size': int(self.total_blank_ssd_size.b),
+                'sizes': self.journal_size.b.as_int(),
+                'size': self.total_blank_ssd_size.b.as_int(),
                 'human_readable_sizes': str(self.journal_size),
                 'human_readable_size': str(self.total_available_journal_space),
             }
@@ -322,11 +330,11 @@ class MixedType(object):
                 data_size = device_size / self.osds_per_device
                 osd = {'data': {}, 'journal': {}, 'used_by_ceph': device.used_by_ceph}
                 osd['data']['path'] = device.path
-                osd['data']['size'] = data_size.b
+                osd['data']['size'] = data_size.b.as_int()
                 osd['data']['percentage'] = 100 / self.osds_per_device
                 osd['data']['human_readable_size'] = str(data_size)
                 osd['journal']['path'] = 'vg: %s' % vg_name
-                osd['journal']['size'] = self.journal_size.b
+                osd['journal']['size'] = self.journal_size.b.as_int()
                 osd['journal']['percentage'] = int(self.journal_size.gb * 100 / vg_free)
                 osd['journal']['human_readable_size'] = str(self.journal_size)
                 osds.append(osd)