Blame SOURCES/bz1384485-01-fix-rsc-update-cmd-when-unable-to-get-agent-metadata.patch

8f8404
From e5fc48f45a60228a82980dcd6d68ca01cf447eac Mon Sep 17 00:00:00 2001
8f8404
From: Ondrej Mular <omular@redhat.com>
8f8404
Date: Tue, 7 Dec 2021 11:58:09 +0100
8f8404
Subject: [PATCH 2/3] fix rsc update cmd when unable to get agent metadata
8f8404
8f8404
`resource update` command failed with a traceback when updating a
8f8404
resource with a non-existing resource agent
8f8404
---
8f8404
 pcs/resource.py                        | 14 ++++++++------
8f8404
 pcs_test/tier1/legacy/test_resource.py | 21 +++++++++++++++++++++
8f8404
 2 files changed, 29 insertions(+), 6 deletions(-)
8f8404
8f8404
diff --git a/pcs/resource.py b/pcs/resource.py
8f8404
index c0e8b0d9..4514338d 100644
8f8404
--- a/pcs/resource.py
8f8404
+++ b/pcs/resource.py
8f8404
@@ -1049,13 +1049,15 @@ def resource_update(lib, args, modifiers, deal_with_guest_change=True):
8f8404
         if report_list:
8f8404
             process_library_reports(report_list)
8f8404
     except lib_ra.ResourceAgentError as e:
8f8404
-        severity = (
8f8404
-            reports.ReportItemSeverity.WARNING
8f8404
-            if modifiers.get("--force")
8f8404
-            else reports.ReportItemSeverity.ERROR
8f8404
-        )
8f8404
         process_library_reports(
8f8404
-            [lib_ra.resource_agent_error_to_report_item(e, severity)]
8f8404
+            [
8f8404
+                lib_ra.resource_agent_error_to_report_item(
8f8404
+                    e,
8f8404
+                    reports.get_severity(
8f8404
+                        reports.codes.FORCE, modifiers.get("--force")
8f8404
+                    ),
8f8404
+                )
8f8404
+            ]
8f8404
         )
8f8404
     except LibraryError as e:
8f8404
         process_library_reports(e.args)
8f8404
diff --git a/pcs_test/tier1/legacy/test_resource.py b/pcs_test/tier1/legacy/test_resource.py
8f8404
index 3f0e08b9..bae0587a 100644
8f8404
--- a/pcs_test/tier1/legacy/test_resource.py
8f8404
+++ b/pcs_test/tier1/legacy/test_resource.py
8f8404
@@ -4879,6 +4879,27 @@ class UpdateInstanceAttrs(
8f8404
             ),
8f8404
         )
8f8404
 
8f8404
+    def test_nonexisting_agent(self):
8f8404
+        agent = "ocf:pacemaker:nonexistent"
8f8404
+        message = (
8f8404
+            f"Agent '{agent}' is not installed or does "
8f8404
+            "not provide valid metadata: Metadata query for "
8f8404
+            f"{agent} failed: Input/output error"
8f8404
+        )
8f8404
+        self.assert_pcs_success(
8f8404
+            f"resource create --force D0 {agent}".split(),
8f8404
+            f"Warning: {message}\n",
8f8404
+        )
8f8404
+
8f8404
+        self.assert_pcs_fail(
8f8404
+            "resource update D0 test=testA".split(),
8f8404
+            f"Error: {message}, use --force to override\n",
8f8404
+        )
8f8404
+        self.assert_pcs_success(
8f8404
+            "resource update --force D0 test=testA".split(),
8f8404
+            f"Warning: {message}\n",
8f8404
+        )
8f8404
+
8f8404
     def test_update_existing(self):
8f8404
         xml = """
8f8404
             <resources>
8f8404
-- 
8f8404
2.31.1
8f8404