[2.6] Commissioning script upload via CLI without name specified causes "Internal Server Error"

Bug #1835289 reported by Vladimir Grevtsev
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Lee Trager
2.6
Fix Released
High
Lee Trager

Bug Description

MAAS 2.6, packages: https://paste.ubuntu.com/p/ZrwwHcqmmZ/

ubuntu@ubuntu-maas:~$ touch ./demo_script.sh # creating an empty file
ubuntu@ubuntu-maas:~$ maas admin commissioning-scripts create content@=./demo_script.sh --debug
500 Internal Server Error

   Content-Length: 30
     Content-Type: text/plain; charset=utf-8
             Date: Wed, 03 Jul 2019 18:20:01 GMT
           Server: TwistedWeb/17.9.0
           Status: 500
             Vary: Cookie
  X-Frame-Options: SAMEORIGIN

No active exception to reraise

ubuntu@ubuntu-maas:~$ sudo tail -n20 /var/log/maas/regiond.log
2019-07-03 18:19:38 regiond: [info] ::1 GET /MAAS/rpc/ HTTP/1.1 --> 200 OK (referrer: -; agent: provisioningserver.rpc.clusterservice.ClusterClientService)
2019-07-03 18:20:01 maasserver: [error] ################################ Exception: No active exception to reraise ################################
2019-07-03 18:20:01 maasserver: [error] Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 277, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/maasserver/api/support.py", line 70, in __call__
    response = upcall(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/views/decorators/vary.py", line 21, in inner_func
    response = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/piston3/resource.py", line 219, in __call__
    srl = emitter(result, typemapper, handler, fields, anonymous)
  File "/usr/lib/python3/dist-packages/piston3/emitters.py", line 69, in __init__
    raise
RuntimeError: No active exception to reraise

If you will add a "name" parameter to CLI command - everything is fine and command will finish successfully:

ubuntu@ubuntu-maas:~$ maas admin commissioning-scripts create content@=./demo_script.sh name=abc --debug
200 OK

   Content-Length: 103
     Content-Type: application/json; charset=utf-8
             Date: Wed, 03 Jul 2019 18:21:36 GMT
           Server: TwistedWeb/17.9.0
           Status: 200
             Vary: Authorization, Cookie
  X-Frame-Options: SAMEORIGIN
  X-Maas-Api-Hash: d61a4a1be732e6544591828d3570921b3c74bdb4

Success.
Machine-readable output follows:
{
    "name": "abc",
    "content": "",
    "resource_uri": "/MAAS/api/2.0/commissioning-scripts/abc"
}
ubuntu@ubuntu-maas:~$

However, if name is specified in script metadata, CLI uploading is not possible even when specifying script name via CLI parameter:

ubuntu@ubuntu-maas:~$ rm demo_script.sh
ubuntu@ubuntu-maas:~$ vim demo_script.sh
ubuntu@ubuntu-maas:~$ cat demo_script.sh
#!/bin/bash -x
# --- Start MAAS 1.0 script metadata ---
# name: 00-hp-array-01-config
# type: commissioning
# title: Configure HP Smart Array controllers on HP systems
# description: Configure HP Smart Array Controllers
# script_type: commissioning
# destructive: True
# tags: configure_hba commissioning
# --- End MAAS 1.0 script metadata ---

echo "hello"
ubuntu@ubuntu-maas:~$ maas admin commissioning-scripts create content@=./demo_script.sh --debug
500 Internal Server Error

   Content-Length: 30
     Content-Type: text/plain; charset=utf-8
             Date: Wed, 03 Jul 2019 18:27:19 GMT
           Server: TwistedWeb/17.9.0
           Status: 500
             Vary: Cookie
  X-Frame-Options: SAMEORIGIN

No active exception to reraise
ubuntu@ubuntu-maas:~$ maas admin commissioning-scripts create content@=./demo_script.sh name=raid_script --debug
500 Internal Server Error

   Content-Length: 30
     Content-Type: text/plain; charset=utf-8
             Date: Wed, 03 Jul 2019 18:27:26 GMT
           Server: TwistedWeb/17.9.0
           Status: 500
             Vary: Cookie
  X-Frame-Options: SAMEORIGIN

No active exception to reraise

Related branches

Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote :

Subscribing field-medium as this is not blocking customer delivery, but customer complained about it.

tags: added: field-medium
Changed in maas:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.7.0alpha1
Lee Trager (ltrager)
Changed in maas:
assignee: nobody → Lee Trager (ltrager)
status: Triaged → In Progress
Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for the report. The related branch fixes the issues. Please be advised that the commissioning API end point is deprecated. It is now suggested to use the nodes-scripts[1] API end point for both commissioning and testing scripts.

[1] https://docs.maas.io/2.6/en/nodes-scripts

Changed in maas:
status: In Progress → Fix Committed
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.

Other bug subscribers

Remote bug watches

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