Blob Blame History Raw
From e1573865543a3d59930b315a40ecd9b7a807e1c1 Mon Sep 17 00:00:00 2001
From: Ondrej Mular <omular@redhat.com>
Date: Mon, 13 Dec 2021 12:48:26 +0100
Subject: [PATCH 3/3] revert of disallowing to clone a group with a stonith
 inside

Originally, this was not fixed properly (it was possible to add a stonith
into a cloned group), therefore to stay consistent, this change is being
reverted. It will be fixed in the future by not allowing stonith to be
placed into a group.
---
 pcs/resource.py                                  | 16 ++--------------
 .../tier1/cib_resource/test_clone_unclone.py     |  8 ++------
 2 files changed, 4 insertions(+), 20 deletions(-)

diff --git a/pcs/resource.py b/pcs/resource.py
index 928477b2..c7cf4c7e 100644
--- a/pcs/resource.py
+++ b/pcs/resource.py
@@ -1697,7 +1697,7 @@ def resource_clone_create(
     ):
         element.parentNode.parentNode.removeChild(element.parentNode)
 
-    def _reject_stonith_clone_report(force_flags, stonith_ids, group_id=None):
+    if element.getAttribute("class") == "stonith":
         process_library_reports(
             [
                 reports.ReportItem(
@@ -1706,24 +1706,12 @@ def resource_clone_create(
                         is_forced=reports.codes.FORCE in force_flags,
                     ),
                     message=reports.messages.CloningStonithResourcesHasNoEffect(
-                        stonith_ids, group_id=group_id
+                        [name]
                     ),
                 )
             ]
         )
 
-    if element.getAttribute("class") == "stonith":
-        _reject_stonith_clone_report(force_flags, [name])
-
-    if element.tagName == "group":
-        stonith_ids = [
-            resource.getAttribute("id")
-            for resource in element.getElementsByTagName("primitive")
-            if resource.getAttribute("class") == "stonith"
-        ]
-        if stonith_ids:
-            _reject_stonith_clone_report(force_flags, stonith_ids, name)
-
     parts = parse_clone_args(argv, promotable=promotable)
     if not update_existing:
         clone_id = parts["clone_id"]
diff --git a/pcs_test/tier1/cib_resource/test_clone_unclone.py b/pcs_test/tier1/cib_resource/test_clone_unclone.py
index 7b0e89f9..4cc4cb3e 100644
--- a/pcs_test/tier1/cib_resource/test_clone_unclone.py
+++ b/pcs_test/tier1/cib_resource/test_clone_unclone.py
@@ -354,12 +354,9 @@ class Clone(
 
     def test_clone_group_with_stonith(self):
         self.set_cib_file(FIXTURE_GROUP_WITH_STONITH)
-        self.assert_pcs_fail(
+        self.assert_effect(
             "resource clone Group".split(),
-            fixture_clone_stonith_msg(group=True),
-        )
-        self.assert_resources_xml_in_cib(
-            fixture_resources_xml(FIXTURE_GROUP_WITH_STONITH)
+            fixture_resources_xml(FIXTURE_CLONED_GROUP_WITH_STONITH),
         )
 
     def test_clone_group_with_stonith_forced(self):
@@ -367,7 +364,6 @@ class Clone(
         self.assert_effect(
             "resource clone Group --force".split(),
             fixture_resources_xml(FIXTURE_CLONED_GROUP_WITH_STONITH),
-            output=fixture_clone_stonith_msg(forced=True, group=True),
         )
 
     def test_promotable_clone(self):
-- 
2.31.1