Commissioning fails due to Lenovo Firmware Version

Bug #1891027 reported by Mark Klein
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Dougal Matthews
2.7
Fix Released
Critical
Dougal Matthews
2.8
Fix Released
Critical
Dougal Matthews

Bug Description

Hello,

I'm trying to commission some Lenovo servers on MaaS 2.8.1. I've tried both stable and edge (7008 and 8492).

It seems to fail in lib/python3.6/site-packages/metadataserver/models/scriptset.py

the problem is the Lenovo firmware is unfortunately reported as: "-[TBE134N-2.61]-"

It looks like it is treating the firmware version itself as a regex, which gives an error: re.error: bad character range N-2 at position 111

(full regiond.log snippet below (this is initial boot example, fails with 500 internal error)

2020-08-07 13:32:16 regiond: [info] 148.187.104.70 GET /MAAS/metadata/2012-03-01/maas-scripts HTTP/1.0 --> 500 INTERNAL_SERVER_ERROR (referrer: -; agent: Python-urllib/3.6)
2020-08-07 13:32:30 maasserver: [error] ################################ Exception: bad character range N-2 at position 111 ################################
2020-08-07 13:32:30 maasserver: [error] Traceback (most recent call last):
  File "/snap/maas/7808/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/utils/views.py", line 291, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/snap/maas/7808/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/api/support.py", line 57, in __call__
    response = upcall(request, *args, **kwargs)
  File "/snap/maas/7808/usr/lib/python3/dist-packages/django/views/decorators/vary.py", line 21, in inner_func
    response = func(*args, **kwargs)
  File "/snap/maas/7808/usr/lib/python3/dist-packages/piston3/resource.py", line 190, in __call__
    result = self.error_handler(e, request, meth, em_format)
  File "/snap/maas/7808/usr/lib/python3/dist-packages/piston3/resource.py", line 188, in __call__
    result = meth(request, *args, **kwargs)
  File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/api/support.py", line 313, in dispatch
    return function(self, request, *args, **kwargs)
  File "/snap/maas/7808/lib/python3.6/site-packages/metadataserver/api.py", line 1231, in read
    script_set.select_for_hardware_scripts()
  File "/snap/maas/7808/lib/python3.6/site-packages/metadataserver/models/scriptset.py", line 481, in select_for_hardware_scripts
    node_hw_regex = re.compile("^%s$" % "|".join(regexes), re.I)
  File "/snap/maas/7808/usr/lib/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/snap/maas/7808/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/snap/maas/7808/usr/lib/python3.6/sre_compile.py", line 562, in compile
    p = sre_parse.parse(p, flags)
  File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 855, in parse
    p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
  File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 765, in _parse
    p = _parse_sub(source, state, sub_verbose, nested + 1)
  File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
    not nested and not items))
  File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 553, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
sre_constants.error: bad character range N-2 at position 111

If I abort the commission and try to use WebUI to commission the server, it errors out at line 241 and doesn't even attempt to do anything.

2020-08-07 14:29:13 maasserver.websockets.protocol: [critical] Error on request (27) machine.action: bad character range N-2 at position 111
 Traceback (most recent call last):
   File "/snap/maas/7808/usr/lib/python3.6/threading.py", line 864, in run
     self._target(*self._args, **self._kwargs)
   File "/snap/maas/7808/lib/python3.6/site-packages/provisioningserver/utils/twisted.py", line 850, in worker
     return target()
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
     task()
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
     task()
 --- <exception caught here> ---
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
     result = inContext.theWork()
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
     inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
     return self.currentContext().callWithContext(ctx, func, *args, **kw)
   File "/snap/maas/7808/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
     return func(*args,**kw)
   File "/snap/maas/7808/lib/python3.6/site-packages/provisioningserver/utils/twisted.py", line 885, in callInContext
     return func(*args, **kwargs)
   File "/snap/maas/7808/lib/python3.6/site-packages/provisioningserver/utils/twisted.py", line 217, in wrapper
     result = func(*args, **kwargs)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/utils/orm.py", line 737, in call_within_transaction
     return func_outside_txn(*args, **kwargs)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/utils/orm.py", line 540, in retrier
     return func(*args, **kwargs)
   File "/snap/maas/7808/usr/lib/python3.6/contextlib.py", line 52, in inner
     return func(*args, **kwds)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/websockets/base.py", line 405, in prep_user_execute
     method_name, method, params
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/websockets/base.py", line 428, in _call_method_track_queries
     result = method(params)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/websockets/handlers/machine.py", line 946, in action
     return action.execute(**extra_params)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/node_action.py", line 168, in execute
     self._execute(*args, **kwargs)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/node_action.py", line 346, in _execute
     script_input=script_input,
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/utils/orm.py", line 721, in call_within_transaction
     return func_within_txn(*args, **kwargs)
   File "/snap/maas/7808/usr/lib/python3.6/contextlib.py", line 52, in inner
     return func(*args, **kwds)
   File "/snap/maas/7808/lib/python3.6/site-packages/maasserver/models/node.py", line 2231, in start_commissioning
     self, testing_scripts, script_input
   File "/snap/maas/7808/lib/python3.6/site-packages/metadataserver/models/scriptset.py", line 179, in create_testing_script_set
     self._add_user_selected_scripts(script_set, scripts, script_input)
   File "/snap/maas/7808/lib/python3.6/site-packages/metadataserver/models/scriptset.py", line 241, in _add_user_selected_scripts
     node_hw_regex = re.compile("^%s$" % "|".join(regexes), re.I)
   File "/snap/maas/7808/usr/lib/python3.6/re.py", line 233, in compile
     return _compile(pattern, flags)
   File "/snap/maas/7808/usr/lib/python3.6/re.py", line 301, in _compile
     p = sre_compile.compile(pattern, flags)
   File "/snap/maas/7808/usr/lib/python3.6/sre_compile.py", line 562, in compile
     p = sre_parse.parse(p, flags)
   File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 855, in parse
     p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
   File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
     not nested and not items))
   File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 765, in _parse
     p = _parse_sub(source, state, sub_verbose, nested + 1)
   File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 416, in _parse_sub
     not nested and not items))
   File "/snap/maas/7808/usr/lib/python3.6/sre_parse.py", line 553, in _parse
     raise source.error(msg, len(this) + 1 + len(that))
 sre_constants.error: bad character range N-2 at position 111

Cheers,
Mark

Tags: cpe-onsite

Related branches

Revision history for this message
Dougal Matthews (d0ugal) wrote :

I can confirm the error and it seems to be for the reason you guessed. We are including the name in the regex itself.

>>> import re
>>> re.compile("-[TBE134N-2.61]-")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/re.py", line 252, in compile
    return _compile(pattern, flags)
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/re.py", line 304, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/sre_compile.py", line 764, in compile
    p = sre_parse.parse(p, flags)
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/sre_parse.py", line 948, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/sre_parse.py", line 443, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/home/dougal/.pyenv/versions/3.8.4/lib/python3.8/sre_parse.py", line 598, in _parse
    raise source.error(msg, len(this) + 1 + len(that))
re.error: bad character range N-2 at position 8

I think we will need to re-work this part of the code to make it safer in situations like this.

Changed in maas:
status: New → Triaged
Dougal Matthews (d0ugal)
Changed in maas:
importance: Undecided → Medium
Revision history for this message
Pedro Guimarães (pguimaraes) wrote :

Hi, I tried to commission with both Bionic and Focal to see if that changes anything, but it does not.
That is a show-stopper on the field.

Revision history for this message
Pedro Guimarães (pguimaraes) wrote :

Subscribed it to ~field-critical

tags: added: cpe-onsite
Changed in maas:
importance: Medium → Critical
assignee: nobody → Lee Trager (ltrager)
Changed in maas:
assignee: Lee Trager (ltrager) → nobody
assignee: nobody → Dougal Matthews (d0ugal)
status: Triaged → In Progress
milestone: none → 2.9.0b1
Revision history for this message
Adam Collard (adam-collard) wrote :

Just to confirm, with the fix in 2.8, this is now available in 2.8/edge

Changed in maas:
status: In Progress → Fix Committed
Lee Trager (ltrager)
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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