Bug 1112695
| Summary: | pcs tracebacks when ocf resource provides invalid metadata xml | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Tomas Jelinek <tojeline> | ||||
| Component: | pcs | Assignee: | Tomas Jelinek <tojeline> | ||||
| Status: | CLOSED ERRATA | QA Contact: | Martin Juricek <mjuricek> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 7.0 | CC: | cfeist, cluster-maint, mjuricek, rsteiger, tojeline | ||||
| Target Milestone: | rc | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| 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
|
Story Points: | --- | ||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2015-03-05 09:20:09 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
|
Description
Tomas Jelinek
2014-06-24 13:53:25 UTC
Created attachment 912003 [details]
proposed fix
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 Upstream commit here: https://github.com/feist/pcs/commit/01f48af78ff0cb7b7b6d77a4e4be2d80a5cb19d6 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
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 |