Comment 1 for bug 1642916

Revision history for this message
Eric Rouleau (xblitz) wrote : Re: [1.9] Unable to delete users with reserved IPs

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.")])