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