RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1112695 - pcs tracebacks when ocf resource provides invalid metadata xml
Summary: pcs tracebacks when ocf resource provides invalid metadata xml
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: pcs
Version: 7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Tomas Jelinek
QA Contact: Martin Juricek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-24 13:53 UTC by Tomas Jelinek
Modified: 2015-03-05 09:20 UTC (History)
5 users (show)

Fixed In Version: pcs-0.9.126-1.el7
Doc Type: Bug Fix
Doc Text:
Cause: resource agent provides an invalid metadata xml Consequence: pcs crashes with exception traceback Fix: catch exceptions when parsing metadata xml and exit gracefully with error message Result: pcs exits gracefully with explanatory error message
Clone Of:
Environment:
Last Closed: 2015-03-05 09:20:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
proposed fix (4.33 KB, patch)
2014-06-25 09:44 UTC, Tomas Jelinek
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0415 0 normal SHIPPED_LIVE pcs bug fix and enhancement update 2015-03-05 14:16:41 UTC

Description Tomas Jelinek 2014-06-24 13:53:25 UTC
Description of problem:
When ocf resource provides an invalid metadata xml, pcs tracebacks in 'pcs resource create' and 'pcs resource update' in case of using that specific resource.

Version-Release number of selected component (if applicable):
pcs-0.9.123

How reproducible:
always

Steps to Reproduce:
1. Create ocf resource script providing an invalid xml, e.g. edit /usr/lib/ocf/resource.d/heartbeat/Dummy
2. run these commands:
pcs resource create dummy Dummy
pcs resource update dummy fake=foo # assuming resource 'dummy' has been created before

Actual results:
pcs crashes with traceback

Expected results:
pcs provides explanatory error message and exits gracefully

Comment 2 Tomas Jelinek 2014-06-25 09:44:13 UTC
Created attachment 912003 [details]
proposed fix

Comment 3 Tomas Jelinek 2014-06-25 09:45:46 UTC
test:

1. Create Dummy resource: 'pcs resource create dummy Dummy'

2. Edit meta_data function in /usr/lib/ocf/resource.d/heartbeat/Dummy so it returns invalid xml, e.g. change "</longdesc>" to "</longdes>"

3. Run 'pcs resource describe Dummy', check that pcs exits with error message and no traceback:
[root@localhost ~]# pcs resource describe Dummy
Error: Unable to parse xml for 'Dummy': mismatched tag: line 17, column 2
[root@localhost ~]# echo $?
1

4. Run 'pcs resource create dummy1 Dummy', check that pcs exits with error message and no traceback:
[root@localhost ~]# pcs resource create dummy1 Dummy
Error: Unable to parse xml for 'ocf:heartbeat:Dummy': mismatched tag: line 17, column 2
[root@localhost ~]# echo $?
1

5. Run 'pcs resource update dummy fake=foo', check that pcs exits with error message and no traceback:
[root@localhost ~]# pcs resource update dummy fake=foo
Error: Unable to parse xml for 'ocf:heartbeat:Dummy': mismatched tag: line 17, column 2
[root@localhost ~]# echo $?
1

6. Restore /usr/lib/ocf/resource.d/heartbeat/Dummy

Comment 4 Chris Feist 2014-07-01 22:42:07 UTC
Upstream commit here:

https://github.com/feist/pcs/commit/01f48af78ff0cb7b7b6d77a4e4be2d80a5cb19d6

Comment 5 Tomas Jelinek 2014-09-11 12:27:33 UTC
Before Fix:
[root@rh70-node1 ~]# rpm -q pcs
pcs-0.9.115-32.el7.x86_64
[root@rh70-node1 ~]# pcs resource create dummy Dummy
[root@rh70-node1 ~]# sed -i.bak -e 's/<\/longdesc>/<\/longdesca>/' /usr/lib/ocf/resource.d/heartbeat/Dummy
[root@rh70-node1 ~]# pcs resource describe Dummy
Error: Unable to parse xml for: Dummy
[root@rh70-node1 ~]# echo $?
1
[root@rh70-node1 ~]# pcs resource update dummy fake=foo
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 135, in <module>
    main(sys.argv[1:])
  File "/usr/sbin/pcs", line 114, in main
    resource.resource_cmd(argv)
  File "/usr/lib/python2.7/site-packages/pcs/resource.py", line 89, in resource_cmd
    resource_update(res_id,argv)
  File "/usr/lib/python2.7/site-packages/pcs/resource.py", line 562, in resource_update
    bad_opts, missing_req_opts = utils.validInstanceAttributes(res_id, params, resource_type)
  File "/usr/lib/python2.7/site-packages/pcs/utils.py", line 1253, in validInstanceAttributes
    root = ET.fromstring(metadata)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: mismatched tag: line 17, column 2
[root@rh70-node1 ~]# pcs resource create dummy1 Dummy
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 135, in <module>
    main(sys.argv[1:])
  File "/usr/sbin/pcs", line 114, in main
    resource.resource_cmd(argv)
  File "/usr/lib/python2.7/site-packages/pcs/resource.py", line 71, in resource_cmd
    resource_create(res_id, res_type, ra_values, op_values, meta_values, clone_opts)
  File "/usr/lib/python2.7/site-packages/pcs/resource.py", line 328, in resource_create
    default_op_values = utils.get_default_op_values(ra_type)
  File "/usr/lib/python2.7/site-packages/pcs/utils.py", line 695, in get_default_op_values
    root = ET.fromstring(metadata)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: mismatched tag: line 17, column 2
[root@rh70-node1 ~]# mv /usr/lib/ocf/resource.d/heartbeat/Dummy.bak /usr/lib/ocf/resource.d/heartbeat/Dummy

After Fix:
[root@rh70-node1 ~]# rpm -q pcs
pcs-0.9.126-1.el7.x86_64
[root@rh70-node1 ~]# pcs resource create dummy Dummy
[root@rh70-node1 ~]# sed -i.bak -e 's/<\/longdesc>/<\/longdesca>/' /usr/lib/ocf/resource.d/heartbeat/Dummy
[root@rh70-node1 ~]# pcs resource describe Dummy
Error: Unable to parse xml for 'Dummy': mismatched tag: line 17, column 2
[root@rh70-node1 ~]# echo $?
1
[root@rh70-node1 ~]# pcs resource update dummy fake=foo
Error: Unable to parse xml for 'ocf:heartbeat:Dummy': mismatched tag: line 17, column 2
[root@rh70-node1 ~]# echo $?
1
[root@rh70-node1 ~]# pcs resource create dummy1 Dummy
Error: Unable to parse xml for 'ocf:heartbeat:Dummy': mismatched tag: line 17, column 2
[root@rh70-node1 ~]# echo $?
1
[root@rh70-node1 ~]# mv /usr/lib/ocf/resource.d/heartbeat/Dummy.bak /usr/lib/ocf/resource.d/heartbeat/Dummy

Comment 9 errata-xmlrpc 2015-03-05 09:20:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0415.html


Note You need to log in before you can comment on or make changes to this bug.