neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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