[2.3] Unable to delete users with reserved IPs

Bug #1642916 reported by Adam Collard
18
This bug affects 3 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Medium
Alberto Donato
2.3
Fix Released
Medium
Unassigned

Bug Description

MAAS Version 1.9.4+bzr4592-0ubuntu1 (trusty1)

Attempting to delete a user and get an ugly 500 Internal server error page after confirming.

Snippet from regiond.log ( https://pastebin.canonical.com/171089/ for formatting )

2016-11-18 10:15:38 [HTTPChannel,10748,127.0.0.1] 500 Error - /MAAS/accounts/tribaal/del/
        Traceback (most recent call last):
          File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 206, in __call__
            response = self.get_response(request)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 236, in get_response
            response = get_response(request)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 210, in get_response
            return django_get_response(request)
          File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 194, in get_response
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        --- <exception caught here> ---
          File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 112, in get_response
            response = wrapped_callback(request, *callback_args, **callback_kwargs)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/views.py", line 189, in view_atomic_with_post_commit_savepoint
            return view_atomic(*args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 339, in inner
            return func(*args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view
            return view_func(request, *args, **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/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 257, in post
            return self.delete(request, *args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/maasserver/views/settings.py", line 116, in delete
            profile.delete()
          File "/usr/lib/python2.7/dist-packages/maasserver/models/userprofile.py", line 82, in delete
            self.user.delete()
          File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 694, in delete
            collector.collect([self])
          File "/usr/lib/python2.7/dist-packages/django/db/models/deletion.py", line 197, in collect
            field.rel.on_delete(self, field, sub_objs, self.using)
          File "/usr/lib/python2.7/dist-packages/django/db/models/deletion.py", line 27, in PROTECT
            sub_objs
        django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'User' because they are referenced through a protected foreign key: 'StaticIPAddress.user'", [<StaticIPAddress: 10.1.100.1:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.9:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.13:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.14:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.15:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.16:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.17:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.18:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.19:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.20:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.3:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.10:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.4:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.11:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.5:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.6:type=USER_RESERVED>, <StaticIPAddress: 10.1.100.7:type=USER_RESERVED>])

Tags: landscape

Related branches

Revision history for this message
Eric Rouleau (xblitz) wrote :

I seem to have the same problem, I had to delete the Reserved IP ranges from the zone before I could delete the user. here is the error:

2017-01-05 15:28:52 maasserver.utils.views: [error] 500 Internal Server Error @ /MAAS/accounts/admin2/del/
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 177, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/django/contrib/auth/decorators.py", line 22, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 71, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 89, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 301, in post
    return self.delete(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/views/settings.py", line 107, in delete
    profile.delete()
  File "/usr/lib/python3/dist-packages/maasserver/models/userprofile.py", line 77, in delete
    self.user.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 28, in PROTECT
    sub_objs
django.db.models.deletion.ProtectedError: ("Cannot delete some instances of model 'User' because they are referenced through a protected foreign key: 'IPRange.user'", [IPRange(subnet_id=2, start_ip='172.0.0.10', end_ip='172.0.0.99', type='dynamic', user_id=3, comment="Added via 'Provide DHCP...' in Web UI.")])

Changed in maas:
milestone: none → 2.3.0
importance: Undecided → Medium
status: New → Triaged
Changed in maas:
milestone: 2.3.0 → 2.3.x
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I changed the version in the bug subject line because it just happened to me with maas 2.3.0-6434-gd354690-0ubuntu1~16.04.1 when deleting an user

summary: - [1.9] Unable to delete users with reserved IPs
+ [12.3] Unable to delete users with reserved IPs
summary: - [12.3] Unable to delete users with reserved IPs
+ [2.3] Unable to delete users with reserved IPs
Alberto Donato (ack)
Changed in maas:
assignee: nobody → Alberto Donato (ack)
status: Triaged → In Progress
Alberto Donato (ack)
Changed in maas:
milestone: 2.3.x → 2.4.0alpha1
milestone: 2.4.0alpha1 → 2.3.x
Changed in maas:
status: In Progress → Fix Committed
Alberto Donato (ack)
Changed in maas:
status: Fix Committed → In Progress
Alberto Donato (ack)
Changed in maas:
status: In Progress → Fix Committed
no longer affects: maas/trunk
Changed in maas:
milestone: 2.3.x → 2.4.0alpha1
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.