Internal server error when trying to stop a node with no power type

Bug #1274912 reported by Graham Binns
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Graham Binns

Bug Description

Now that bug 1274871 is fixed, it's possible for a Node to exist without a known power type (in effect, manually-power on and off only). MAAS can't handle stopping nodes with no power type set.

To reproduce:
 - Commission a node.
 - Using `maas shell`, set the Node's power type to '':

>>> from maasserver.models.node import Node
>>> n = Node.objects.get(system_id='<system_id>')
>>> n.power_type = ''
>>> n.save()

 - On the Node page, click "Start node" and start the node manually (since it has no power type, MAAS can't start it for you).
 - On the Node page, click "Stop node".

You'll see a white default apache "Internal Server Error" page.

If you try to stop the node through the CLI, you'll see something like this:

ubuntu@ubuntu:~⟫ maas-cli maas node stop node-07307b52-8a72-11e3-970d-000c29376b22
Node power type is unconfigured

Either way, the node stays up in MAAS: essentially there's no way to mark it stopped without using `maas shell` to change the status of the node.

maas.log shows a perfectly cromulent error in both cases:

ERROR 2014-01-31 12:25:46,175 django.request Internal Server Error: /MAAS/nodes/node-07307b52-8a72-11e3-970d-000c29376b22/view/
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 114, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/maasserver/views/nodes.py", line 453, in dispatch
    return super(NodeView, self).dispatch(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/base.py", line 87, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/edit.py", line 228, in post
    return super(BaseUpdateView, self).post(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/edit.py", line 171, in post
    return self.form_valid(form)
  File "/usr/lib/python2.7/dist-packages/django/views/generic/edit.py", line 147, in form_valid
    self.object = form.save()
  File "/usr/lib/python2.7/dist-packages/maasserver/forms.py", line 529, in save
    message = action.execute(allow_redirect=allow_redirect)
  File "/usr/lib/python2.7/dist-packages/maasserver/node_action.py", line 264, in execute
    self.node.release()
  File "/usr/lib/python2.7/dist-packages/maasserver/models/node.py", line 788, in release
    Node.objects.stop_nodes([self.system_id], self.owner)
  File "/usr/lib/python2.7/dist-packages/maasserver/models/node.py", line 302, in stop_nodes
    node_power_type = node.get_effective_power_type()
  File "/usr/lib/python2.7/dist-packages/maasserver/models/node.py", line 696, in get_effective_power_type
    raise ValueError("Node power type is unconfigured")
ValueError: Node power type is unconfigured

MAAS ought to be able to handle this properly; it handles *starting* nodes with no power type perfectly fine.

Related branches

Revision history for this message
Graham Binns (gmb) wrote :

The workaround is to set the power type to wake-on-LAN before trying to stop the node, but really you shouldn't have to do that to make this work.

description: updated
tags: added: maas-cli
Revision history for this message
Raphaël Badin (rvb) wrote :

start_nodes happily skips not with no power type:
        for node in nodes:
            power_params = node.get_effective_power_parameters()
            try:
                node_power_type = node.get_effective_power_type()
            except ValueError:
                continue

Although I think a warning should be issued, stop_nodes should do the same.

Changed in maas:
importance: High → Critical
tags: removed: ui
Raphaël Badin (rvb)
tags: added: trivial
Graham Binns (gmb)
Changed in maas:
assignee: nobody → Graham Binns (gmb)
status: Triaged → In Progress
Graham Binns (gmb)
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: none → 14.04
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.