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