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