Blame SOURCES/0004-allow-removing-btrfs-volumes-without-btrfs-support.patch

3187bc
From fd07d14ad1f19c700d5344c8af11be6a1e314ceb Mon Sep 17 00:00:00 2001
3187bc
From: Vojtech Trefny <vtrefny@redhat.com>
3187bc
Date: Wed, 12 Sep 2018 10:45:41 +0200
3187bc
Subject: [PATCH 1/2] Allow removing btrfs volumes without btrfs support
3187bc
3187bc
Btrfs volumes are removed using wipefs so we don't need to check
3187bc
for device dependencies availability when removing the volume
3187bc
(btrfs support depends on libblockdev btrfs plugin).
3187bc
3187bc
Resolves: rhbz#1605213
3187bc
---
3187bc
 blivet/deviceaction.py | 23 ++++++++++++++++++-----
3187bc
 1 file changed, 18 insertions(+), 5 deletions(-)
3187bc
3187bc
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
3187bc
index 3e337e18..b3e9e5f1 100644
3187bc
--- a/blivet/deviceaction.py
3187bc
+++ b/blivet/deviceaction.py
3187bc
@@ -160,15 +160,19 @@ def __init__(self, device):
3187bc
         if not isinstance(device, StorageDevice):
3187bc
             raise ValueError("arg 1 must be a StorageDevice instance")
3187bc
 
3187bc
-        unavailable_dependencies = device.unavailable_dependencies
3187bc
-        if unavailable_dependencies:
3187bc
-            dependencies_str = ", ".join(str(d) for d in unavailable_dependencies)
3187bc
-            raise DependencyError("device type %s requires unavailable_dependencies: %s" % (device.type, dependencies_str))
3187bc
-
3187bc
         self.device = device
3187bc
+
3187bc
+        self._check_device_dependencies()
3187bc
+
3187bc
         self.container = getattr(self.device, "container", None)
3187bc
         self._applied = False
3187bc
 
3187bc
+    def _check_device_dependencies(self):
3187bc
+        unavailable_dependencies = self.device.unavailable_dependencies
3187bc
+        if unavailable_dependencies:
3187bc
+            dependencies_str = ", ".join(str(d) for d in unavailable_dependencies)
3187bc
+            raise DependencyError("device type %s requires unavailable_dependencies: %s" % (self.device.type, dependencies_str))
3187bc
+
3187bc
     def apply(self):
3187bc
         """ apply changes related to the action to the device(s) """
3187bc
         self._applied = True
3187bc
@@ -379,6 +383,15 @@ def __init__(self, device):
3187bc
         # XXX should we insist that device.fs be None?
3187bc
         DeviceAction.__init__(self, device)
3187bc
 
3187bc
+    def _check_device_dependencies(self):
3187bc
+        if self.device.type == "btrfs volume":
3187bc
+            # XXX destroying a btrfs volume is a special case -- we don't destroy
3187bc
+            # the device, but use wipefs to destroy format on its parents so we
3187bc
+            # don't need btrfs plugin or btrfs-progs for this
3187bc
+            return
3187bc
+
3187bc
+        super(ActionDestroyDevice, self)._check_device_dependencies()
3187bc
+
3187bc
     def execute(self, callbacks=None):
3187bc
         super(ActionDestroyDevice, self).execute(callbacks=callbacks)
3187bc
         self.device.destroy()
3187bc
3187bc
From b9f1b4acb654c5fb70be1a2200bcf3a34dcde467 Mon Sep 17 00:00:00 2001
3187bc
From: Vojtech Trefny <vtrefny@redhat.com>
3187bc
Date: Mon, 17 Sep 2018 10:25:24 +0200
3187bc
Subject: [PATCH 2/2] Check device dependencies only for device actions
3187bc
3187bc
We don't want to check device dependencies for format actions.
3187bc
It should be possible to for example format an opened LUKS device
3187bc
without libblockdev crypto plugin.
3187bc
3187bc
Related: rhbz#1605213
3187bc
---
3187bc
 blivet/deviceaction.py                  | 3 ++-
3187bc
 tests/devices_test/dependencies_test.py | 4 ----
3187bc
 2 files changed, 2 insertions(+), 5 deletions(-)
3187bc
3187bc
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
3187bc
index b3e9e5f1..14a06ff0 100644
3187bc
--- a/blivet/deviceaction.py
3187bc
+++ b/blivet/deviceaction.py
3187bc
@@ -162,7 +162,8 @@ def __init__(self, device):
3187bc
 
3187bc
         self.device = device
3187bc
 
3187bc
-        self._check_device_dependencies()
3187bc
+        if self.is_device:
3187bc
+            self._check_device_dependencies()
3187bc
 
3187bc
         self.container = getattr(self.device, "container", None)
3187bc
         self._applied = False
3187bc
diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py
3187bc
index 0b44493e..e6b5bdb4 100644
3187bc
--- a/tests/devices_test/dependencies_test.py
3187bc
+++ b/tests/devices_test/dependencies_test.py
3187bc
@@ -97,10 +97,6 @@ def test_availability_mdraidplugin(self):
3187bc
             ActionCreateDevice(self.luks)
3187bc
         with self.assertRaises(DependencyError):
3187bc
             ActionDestroyDevice(self.dev)
3187bc
-        with self.assertRaises(DependencyError):
3187bc
-            ActionCreateFormat(self.dev)
3187bc
-        with self.assertRaises(DependencyError):
3187bc
-            ActionDestroyFormat(self.dev)
3187bc
 
3187bc
     def _clean_up(self):
3187bc
         availability.BLOCKDEV_MDRAID_PLUGIN._method = self.mdraid_method