Skip to content

Commit

Permalink
fix rsc update cmd when unable to get agent metadata
Browse files Browse the repository at this point in the history
`resource update` command failed with a traceback when updating a
resource with a non-existing resource agent
  • Loading branch information
ondrejmular committed Dec 7, 2021
1 parent 9376a6c commit 674785c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,8 +5,11 @@
### Fixed
- Pcs was not automatically enabling corosync-qdevice when adding a quorum
device to a cluster (broken since pcs-0.10.9) ([rhbz#2028902])
- `resource update` command exiting with a traceback when updating a resource
with a non-existing resource agent ([rhbz#1384485])

[rhbz#2028902]: https://bugzilla.redhat.com/show_bug.cgi?id=2028902
[rhbz#1384485]: https://bugzilla.redhat.com/show_bug.cgi?id=1384485


## [0.10.12] - 2021-11-30
Expand Down
14 changes: 8 additions & 6 deletions pcs/resource.py
Expand Up @@ -1049,13 +1049,15 @@ def resource_update(lib, args, modifiers, deal_with_guest_change=True):
if report_list:
process_library_reports(report_list)
except lib_ra.ResourceAgentError as e:
severity = (
reports.ReportItemSeverity.WARNING
if modifiers.get("--force")
else reports.ReportItemSeverity.ERROR
)
process_library_reports(
[lib_ra.resource_agent_error_to_report_item(e, severity)]
[
lib_ra.resource_agent_error_to_report_item(
e,
reports.get_severity(
reports.codes.FORCE, modifiers.get("--force")
),
)
]
)
except LibraryError as e:
process_library_reports(e.args)
Expand Down
21 changes: 21 additions & 0 deletions pcs_test/tier1/legacy/test_resource.py
Expand Up @@ -4879,6 +4879,27 @@ def testBadInstanceVariables(self):
),
)

def test_nonexisting_agent(self):
agent = "ocf:pacemaker:nonexistent"
message = (
f"Agent '{agent}' is not installed or does "
"not provide valid metadata: Metadata query for "
f"{agent} failed: Input/output error"
)
self.assert_pcs_success(
f"resource create --force D0 {agent}".split(),
f"Warning: {message}\n",
)

self.assert_pcs_fail(
"resource update D0 test=testA".split(),
f"Error: {message}, use --force to override\n",
)
self.assert_pcs_success(
"resource update --force D0 test=testA".split(),
f"Warning: {message}\n",
)

def test_update_existing(self):
xml = """
<resources>
Expand Down

0 comments on commit 674785c

Please sign in to comment.