[2.0 beta 2] Cannot delete a rack controller that was previously a 'machine'

Bug #1570995 reported by Andres Rodriguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Lee Trager

Bug Description

I had a machine in MAAS which I deployed. After deployment, I manually installed maas-rack-controller and pointed it to the Region Controller, so a new rack appeared.

Then I configured this rack controller as secondary rack controller for a VLAN.

Finally, I tried to delete this new rack controller and came across this error in the UI:

The delete action for 1 controller failed with error: ("Cannot delete some instances of model 'VLAN' because they are referenced through a protected foreign key: 'PhysicalInterface.vlan'", [<PhysicalInterface: name=usb0, type=physical, mac=00:0e:c6:88:b7:9f>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:17:d2>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:16:d0>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7c:4d:75>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7e:b4:99>])

logs:

==> /var/log/maas/regiond.log <==
2016-04-15 13:45:19 [-] Error on request (118) controller.action: ("Cannot delete some instances of model 'VLAN' because they are referenced through a protected foreign key: 'PhysicalInterface.vlan'", [<PhysicalInterface: name=usb0, type=physical, mac=00:0e:c6:88:b7:9f>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:17:d2>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:16:d0>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7c:4d:75>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7e:b4:99>])
        Traceback (most recent call last):
          File "/usr/lib/python3.5/threading.py", line 862, in run
            self._target(*self._args, **self._kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 841, in worker
            return target()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
            task()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
            task()
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 246, in inContext
            result = inContext.theWork()
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 262, in <lambda>
            inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 81, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 874, in callInContext
            return func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 516, in call_within_transaction
            return func_outside_txn(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 343, in retrier
            return func(*args, **kwargs)
          File "/usr/lib/python3.5/contextlib.py", line 30, in inner
            return func(*args, **kwds)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/machine.py", line 676, in action
            return action.execute(**extra_params)
          File "/usr/lib/python3/dist-packages/maasserver/node_action.py", line 193, in execute
            self.node.delete()
          File "/usr/lib/python3/dist-packages/maasserver/models/node.py", line 1692, in delete
            super(Node, self).delete()
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 895, in delete
            collector.collect([self])
          File "/usr/lib/python3/dist-packages/django/db/models/deletion.py", line 229, in collect
            field.rel.on_delete(self, field, sub_objs, self.using)
          File "/usr/lib/python3/dist-packages/django/db/models/deletion.py", line 18, in CASCADE
            source_attr=field.name, nullable=field.null)
          File "/usr/lib/python3/dist-packages/django/db/models/deletion.py", line 229, in collect
            field.rel.on_delete(self, field, sub_objs, self.using)
          File "/usr/lib/python3/dist-packages/django/db/models/deletion.py", line 28, in PROTECT
            sub_objs
        django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'VLAN' because they are referenced through a protected foreign key: 'PhysicalInterface.vlan'", [<PhysicalInterface: name=usb0, type=physical, mac=00:0e:c6:88:b7:9f>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:17:d2>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7d:16:d0>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7c:4d:75>, <PhysicalInterface: name=enp0s25, type=physical, mac=b8:ae:ed:7e:b4:99>])

Related branches

description: updated
Changed in maas:
importance: Undecided → Critical
Revision history for this message
Lee Trager (ltrager) wrote :

This is because the rack is still linked to the VLAN as a secondary_rack. We can solve this in one of two ways

1. Automatically delete the link(s) between the to be deleted rack and any VLAN it is associated with
2. Error and inform the user of the VLAN(s) the rack is associated with

We don't currently have a way to set the primary and secondary racks for a VLAN in the UI so option 2 will cause the UI to produce an error message which can only be resolved by using the CLI.

Changed in maas:
assignee: nobody → Lee Trager (ltrager)
status: New → In Progress
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.