Blame SOURCES/bz2032997-01-skip-checking-of-scsi-devices-to-be-removed.patch

9e0fa3
From 082bded126151e4f4b4667a1d8337db741828da6 Mon Sep 17 00:00:00 2001
9e0fa3
From: Miroslav Lisik <mlisik@redhat.com>
9e0fa3
Date: Thu, 16 Dec 2021 14:12:58 +0100
9e0fa3
Subject: [PATCH 1/5] skip checking of scsi devices to be removed before
9e0fa3
 unfencing to be added devices
9e0fa3
9e0fa3
---
9e0fa3
 pcs/lib/commands/scsi.py                 |  3 ++-
9e0fa3
 pcs_test/tier0/lib/commands/test_scsi.py | 21 +++++++++++++++++----
9e0fa3
 2 files changed, 19 insertions(+), 5 deletions(-)
9e0fa3
9e0fa3
diff --git a/pcs/lib/commands/scsi.py b/pcs/lib/commands/scsi.py
9e0fa3
index ff20a563..ab732805 100644
9e0fa3
--- a/pcs/lib/commands/scsi.py
9e0fa3
+++ b/pcs/lib/commands/scsi.py
9e0fa3
@@ -31,7 +31,8 @@ def unfence_node(
9e0fa3
         return
9e0fa3
     fence_scsi_bin = os.path.join(settings.fence_agent_binaries, "fence_scsi")
9e0fa3
     fenced_devices = []
9e0fa3
-    for device in original_devices:
9e0fa3
+    # do not check devices being removed
9e0fa3
+    for device in sorted(set(original_devices) & set(updated_devices)):
9e0fa3
         stdout, stderr, return_code = env.cmd_runner().run(
9e0fa3
             [
9e0fa3
                 fence_scsi_bin,
9e0fa3
diff --git a/pcs_test/tier0/lib/commands/test_scsi.py b/pcs_test/tier0/lib/commands/test_scsi.py
9e0fa3
index 8ef9836a..bc2357a9 100644
9e0fa3
--- a/pcs_test/tier0/lib/commands/test_scsi.py
9e0fa3
+++ b/pcs_test/tier0/lib/commands/test_scsi.py
9e0fa3
@@ -13,10 +13,13 @@ class TestUnfenceNode(TestCase):
9e0fa3
         self.old_devices = ["device1", "device3"]
9e0fa3
         self.new_devices = ["device3", "device0", "device2"]
9e0fa3
         self.added_devices = set(self.new_devices) - set(self.old_devices)
9e0fa3
+        self.check_devices = sorted(
9e0fa3
+            set(self.old_devices) & set(self.new_devices)
9e0fa3
+        )
9e0fa3
         self.node = "node1"
9e0fa3
 
9e0fa3
     def test_success_devices_to_unfence(self):
9e0fa3
-        for old_dev in self.old_devices:
9e0fa3
+        for old_dev in self.check_devices:
9e0fa3
             self.config.runner.scsi.get_status(
9e0fa3
                 self.node, old_dev, name=f"runner.scsi.is_fenced.{old_dev}"
9e0fa3
             )
9e0fa3
@@ -38,9 +41,19 @@ class TestUnfenceNode(TestCase):
9e0fa3
         )
9e0fa3
         self.env_assist.assert_reports([])
9e0fa3
 
9e0fa3
+    def test_success_replace_unavailable_device(self):
9e0fa3
+        self.config.runner.scsi.unfence_node(self.node, {"device2"})
9e0fa3
+        scsi.unfence_node(
9e0fa3
+            self.env_assist.get_env(),
9e0fa3
+            self.node,
9e0fa3
+            {"device1"},
9e0fa3
+            {"device2"},
9e0fa3
+        )
9e0fa3
+        self.env_assist.assert_reports([])
9e0fa3
+
9e0fa3
     def test_unfencing_failure(self):
9e0fa3
         err_msg = "stderr"
9e0fa3
-        for old_dev in self.old_devices:
9e0fa3
+        for old_dev in self.check_devices:
9e0fa3
             self.config.runner.scsi.get_status(
9e0fa3
                 self.node, old_dev, name=f"runner.scsi.is_fenced.{old_dev}"
9e0fa3
             )
9e0fa3
@@ -98,7 +111,7 @@ class TestUnfenceNode(TestCase):
9e0fa3
 
9e0fa3
     def test_unfencing_skipped_devices_are_fenced(self):
9e0fa3
         stdout_off = "Status: OFF"
9e0fa3
-        for old_dev in self.old_devices:
9e0fa3
+        for old_dev in self.check_devices:
9e0fa3
             self.config.runner.scsi.get_status(
9e0fa3
                 self.node,
9e0fa3
                 old_dev,
9e0fa3
@@ -116,7 +129,7 @@ class TestUnfenceNode(TestCase):
9e0fa3
             [
9e0fa3
                 fixture.info(
9e0fa3
                     report_codes.STONITH_UNFENCING_SKIPPED_DEVICES_FENCED,
9e0fa3
-                    devices=sorted(self.old_devices),
9e0fa3
+                    devices=sorted(self.check_devices),
9e0fa3
                 )
9e0fa3
             ]
9e0fa3
         )
9e0fa3
-- 
9e0fa3
2.31.1
9e0fa3