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