MaaS Internal Server Error 500 while parsing tags with namespaces in definition upon commissioning

Bug #1255479 reported by Phil
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Gavin Panella
1.4
Fix Released
Critical
Gavin Panella
maas (Ubuntu)
Fix Released
High
Andres Rodriguez
Saucy
Won't Fix
High
Andres Rodriguez
Trusty
Fix Released
High
Andres Rodriguez

Bug Description

Hello,

Description: While commissioning a node and checking stdout via a Dell RAC Console session, one can see

request to http://$MaaSServer/MAAS/metadata//2012-03-01/ failed, sleeping HTTP Error 500: INTERNAL SERVER ERROR

during the last steps. The maas.log file shows:

ERROR 2013-11-26 15:32:48,332 maasserver ################################ Exception: Undefined namespace prefix ################################
ERROR 2013-11-26 15:32:48,332 maasserver Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/lib/python2.7/dist-packages/django/views/decorators/vary.py", line 19, in inner_func
response = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 167, in call
result = self.error_handler(e, request, meth, em_format)
File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 165, in call
result = meth(request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/maasserver/api_support.py", line 147, in dispatch
return function(self, request, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/metadataserver/api.py", line 247, in signal
self._store_commissioning_results(node, request)
File "/usr/lib/python2.7/dist-packages/metadataserver/api.py", line 207, in _store_commissioning_results
exit_status=script_result)
File "/usr/lib/python2.7/dist-packages/metadataserver/models/commissioningscript.py", line 173, in update_hardware_details
has_tag = evaluator(tag.definition)
File "xpath.pxi", line 322, in lxml.etree.XPathElementEvaluator.call (src/lxml/lxml.etree.c:132785)
File "xpath.pxi", line 242, in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:131890)
File "xpath.pxi", line 227, in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:131718)
XPathEvalError: Undefined namespace prefix

---
Problem being a Tag:

:~$ maas-cli $profile tags new name='bsnode' comment="$MyComment" definition='//lshw:node[@id="$ID"]/lshw:serial = "$SERIAL"'
(naturally, all things dollar have actual values in the command used.)

created prior to commissioning. Commissioning fails for all nodes.

In /src/metadataserver/models/commissioningscript.py, in method update_hardware_details. The lshw output used in the
method (I assume retrieved from the node) has no namespace prefixes. Though the output viewable in MaaS does have these and
the XPath expression needs them for the tag to work/be applied to the proper node.

I have altered the method to:

- check if the received xml output does have xmlns definitions on the root element
- if so, checking for and subsequently stripping off namespace prefixes from the definition.

I'm not sure how robust the patch is.
I don't know if this is the proper procedure, posting a patch here
I don't know if the patch is in the correct format.
Any tip of how to do this in the future would be much appreciated.

I wasn't able, due to time constraints, to quickly find a convention, if existing, for xml namespace prefixes. Thus the regex uses
lower and uppercase letters. Maybe this is useful for someone who's going to fix this. It works for me but I have limited time to
test other scenarios.

Greetings,
Phil

Related branches

Revision history for this message
Phil (p.g.sonntag) wrote :
Revision history for this message
Gavin Panella (allenap) wrote :

Thanks for discovering this and reporting it. This is weird, to me at least: I changed that code to work with namespaces, but it appears that the change got lost in the wash somewhere, a merge conflict gone wrong perhaps.

Changed in maas:
status: New → Triaged
importance: Undecided → Critical
Revision history for this message
Gavin Panella (allenap) wrote :

Fwiw, the fix for this deserves to be back-ported to 1.4 and release via an SRU to 13.10.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

Phil,

> I don't know if this is the proper procedure, posting a patch here
> I don't know if the patch is in the correct format.
> Any tip of how to do this in the future would be much appreciated.

Posting a patch here is fine, we can take it and land it. Ideally it would be a merge proposal against the trunk branch, with tests, but we can't all get what we want :)

Changed in maas:
milestone: none → 14.04
Gavin Panella (allenap)
Changed in maas:
assignee: nobody → Gavin Panella (allenap)
status: Triaged → In Progress
Gavin Panella (allenap)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas (Ubuntu):
assignee: nobody → Andres Rodriguez (andreserl)
Changed in maas (Ubuntu Saucy):
assignee: nobody → Andres Rodriguez (andreserl)
James Page (james-page)
Changed in maas (Ubuntu Saucy):
importance: Undecided → High
Changed in maas (Ubuntu Trusty):
importance: Undecided → High
Changed in maas (Ubuntu Saucy):
status: New → Triaged
Changed in maas (Ubuntu Trusty):
status: New → Triaged
Changed in maas (Ubuntu Trusty):
status: Triaged → Fix Released
Changed in maas:
status: Fix Committed → Fix Released
Revision history for this message
Rolf Leggewie (r0lf) wrote :

saucy has seen the end of its life and is no longer receiving any updates. Marking the saucy task for this ticket as "Won't Fix".

Changed in maas (Ubuntu Saucy):
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.