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