Blame SOURCES/0015-ActionDestroyDevice-should-not-obsolete-ActionRemove.patch

f45bfb
From 950f51a4cc041fe1b8a98b17e4828857b7423e55 Mon Sep 17 00:00:00 2001
f45bfb
From: Vojtech Trefny <vtrefny@redhat.com>
f45bfb
Date: Wed, 13 Apr 2022 15:43:45 +0200
f45bfb
Subject: [PATCH] ActionDestroyDevice should not obsolete ActionRemoveMember
f45bfb
f45bfb
If we want to remove a PV from a VG and then remove the PV device,
f45bfb
the ActionDestroyDevice must not obsolete the ActionRemoveMember
f45bfb
action. Eventhough we are going to remove the device, we still
f45bfb
need to call "vgreduce" first.
f45bfb
f45bfb
Resolves: rhbz#2076958
f45bfb
---
f45bfb
 blivet/deviceaction.py | 10 +++++-----
f45bfb
 tests/action_test.py   |  7 +++++++
f45bfb
 2 files changed, 12 insertions(+), 5 deletions(-)
f45bfb
f45bfb
diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
f45bfb
index 0458e4be..78e113bf 100644
f45bfb
--- a/blivet/deviceaction.py
f45bfb
+++ b/blivet/deviceaction.py
f45bfb
@@ -463,8 +463,8 @@ class ActionDestroyDevice(DeviceAction):
f45bfb
             - obsoletes all actions w/ lower id that act on the same device,
f45bfb
               including self, if device does not exist
f45bfb
 
f45bfb
-            - obsoletes all but ActionDestroyFormat actions w/ lower id on the
f45bfb
-              same device if device exists
f45bfb
+            - obsoletes all but ActionDestroyFormat and ActionRemoveMember actions
f45bfb
+              w/ lower id on the same device if device exists
f45bfb
 
f45bfb
             - obsoletes all actions that add a member to this action's
f45bfb
               (container) device
f45bfb
@@ -474,9 +474,9 @@ class ActionDestroyDevice(DeviceAction):
f45bfb
         if action.device.id == self.device.id:
f45bfb
             if self.id >= action.id and not self.device.exists:
f45bfb
                 rc = True
f45bfb
-            elif self.id > action.id and \
f45bfb
-                    self.device.exists and \
f45bfb
-                    not (action.is_destroy and action.is_format):
f45bfb
+            elif self.id > action.id and self.device.exists and \
f45bfb
+                    not ((action.is_destroy and action.is_format) or
f45bfb
+                         action.is_remove):
f45bfb
                 rc = True
f45bfb
             elif action.is_add and (action.device == self.device):
f45bfb
                 rc = True
f45bfb
diff --git a/tests/action_test.py b/tests/action_test.py
f45bfb
index 1e84c20b..b3608047 100644
f45bfb
--- a/tests/action_test.py
f45bfb
+++ b/tests/action_test.py
f45bfb
@@ -1198,6 +1198,13 @@ class DeviceActionTestCase(StorageTestCase):
f45bfb
         self.assertEqual(create_sdc2.requires(remove_sdc1), False)
f45bfb
         self.assertEqual(remove_sdc1.requires(create_sdc2), False)
f45bfb
 
f45bfb
+        # destroy sdc1, the ActionRemoveMember should not be obsoleted
f45bfb
+        sdc1.exists = True
f45bfb
+        destroy_sdc1 = ActionDestroyDevice(sdc1)
f45bfb
+        destroy_sdc1.apply()
f45bfb
+        self.assertFalse(destroy_sdc1.obsoletes(remove_sdc1))
f45bfb
+        self.assertTrue(destroy_sdc1.requires(remove_sdc1))
f45bfb
+
f45bfb
     def test_action_sorting(self, *args, **kwargs):
f45bfb
         """ Verify correct functioning of action sorting. """
f45bfb
 
f45bfb
-- 
f45bfb
2.35.3
f45bfb