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

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