neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

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

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