Error message when trying to reserve the same static IP twice is unhelpful

Bug #1383231 reported by Dimiter Naydenov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Graham Binns

Bug Description

Using the MAAS CLI I was able to do this twice in a row:

$ maas maas-user ipaddresses reserve network=192.168.50.0/24 requested_address=192.168.50.100

No error was reported on the second run. I was expecting something like "192.168.50.100 is already reserved".

Then, trying to release "192.168.50.100" reservation twice, this happened:

$ maas maas-user ipaddresses release ip=192.168.50.100
null

$ maas maas-user ipaddresses release ip=192.168.50.100
Not Found

There's nothing relevant in the log files. I have the "192.168.50.0/24" network configured as Manage DNS and DHCP on the single cluster controller's eth0 interface, having a static range 192.168.50.100 - 192.168.50.200.

$ dpkg -l '*maas*'|cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===================================-====================================-============-===============================================================================
ii maas 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server all-in-one metapackage
ii maas-cli 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS command line API tool
ii maas-cluster-controller 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server cluster controller
ii maas-common 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server common files
ii maas-dhcp 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS DHCP server
ii maas-dns 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS DNS server
un maas-proxy <none> <none> (no description available)
ii maas-region-controller 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server complete region controller
ii maas-region-controller-min 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS Server minimum region controller
ii python-django-maas 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server Django web framework
ii python-maas-client 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS python API client
ii python-maas-provisioningserver 1.7.0~beta5+bzr3198-0ubuntu1~trusty1 all MAAS server provisioning libraries

Tags: api trivial

Related branches

Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Sorry, so I got a bit confused -- there's no duplicate created, but also there's no error message about the duplicate:

$ maas maas-user ipaddresses reserve network=192.168.50.0/24 requested_address=192.168.50.100
{
    "alloc_type": 4,
    "ip": "192.168.50.100",
    "resource_uri": "/MAAS/api/1.0/ipaddresses/",
    "created": "2014-10-20T13:22:07.252"
}
(first run)

$ maas maas-user ipaddresses reserve network=192.168.50.0/24 requested_address=192.168.50.100

(second run)

After second run "ipaddresses read" does not show more than one 192.168.50.100 address.

So I guess the bug report is about a better error message. Also it will be nicer to have a better message when "requested_address" is invalid:

$ maas maas-user ipaddresses reserve network=192.168.50.0/24 requested_address=invalid
failed to detect a valid IP address from u'invalid'

In the case above there's this traceback in /var/logs/maas/maas-django.log:
ERROR 2014-10-20 13:25:06,078 maasserver ################################ Exception: failed to detect a valid IP address from u'invalid' ################################
ERROR 2014-10-20 13:25:06,081 maasserver Traceback (most recent call last):
  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/django/views/decorators/vary.py", line 19, in inner_func
    response = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 167, in __call__
    result = self.error_handler(e, request, meth, em_format)
  File "/usr/lib/python2.7/dist-packages/piston/resource.py", line 165, in __call__
    result = meth(request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/maasserver/api/support.py", line 189, in dispatch
    return function(self, request, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/maasserver/api/ip_addresses.py", line 103, in reserve
    request.user, interface, requested_address)
  File "/usr/lib/python2.7/dist-packages/maasserver/api/ip_addresses.py", line 67, in claim_ip
    user=user)
  File "/usr/lib/python2.7/dist-packages/maasserver/models/staticipaddress.py", line 178, in allocate_new
    requested_address = IPAddress(requested_address)
  File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 315, in __init__
    'address from %r' % addr)
AddrFormatError: failed to detect a valid IP address from u'invalid'

Changed in maas:
status: New → Invalid
status: Invalid → New
summary: - Can reserve the same static IP twice and cannot release it completely
+ Better error message when trying to reserve the same static IP twice
description: updated
Graham Binns (gmb)
summary: - Better error message when trying to reserve the same static IP twice
+ Error message when trying to reserve the same static IP twice is
+ unhelpful
Changed in maas:
status: New → Triaged
importance: Undecided → High
description: updated
tags: added: trivial
Changed in maas:
milestone: none → next
Graham Binns (gmb)
Changed in maas:
status: Triaged → In Progress
assignee: nobody → Graham Binns (gmb)
Changed in maas:
status: In Progress → Fix Committed
Christian Reis (kiko)
Changed in maas:
milestone: next → 1.7.1
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.