Trying to assign an IP address statically to a device results in builtins.AttributeError: 'NoneType' object has no attribute 'link_subnet'

Bug #1558635 reported by Andres Rodriguez on 2016-03-17
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Critical
Gavin Panella

Bug Description

I have subnet where I'm managing DHCP. This is not on fabric-0. That being said, I'm trying to add a device with an IP that's statically assigned in this subnet.

However, I see the following error:

2016-03-17 11:33:25 [-] Error on request (49) device.create: 'NoneType' object has no attribute 'link_subnet'
 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 794, 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/maasserver/utils/orm.py", line 448, in call_within_transaction
     return func_outside_txn(*args, **kwargs)
   File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 275, 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/device.py", line 272, in create
     interface.link_subnet(
 builtins.AttributeError: 'NoneType' object has no attribute 'link_subnet'

Related branches

Andres Rodriguez (andreserl) wrote :

I Same happens if I try to create a device with 'Dynamic' IP address assignment:

016-03-17 11:36:17 [-] Error on request (51) device.create: 'NoneType' object has no attribute 'link_subnet'
 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 794, 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/maasserver/utils/orm.py", line 448, in call_within_transaction
     return func_outside_txn(*args, **kwargs)
   File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 275, 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/device.py", line 263, in create
     interface.link_subnet(INTERFACE_LINK_TYPE.DHCP, None)
 builtins.AttributeError: 'NoneType' object has no attribute 'link_subnet'

description: updated
Gavin Panella (allenap) wrote :

Confirmed.

Changed in maas:
status: New → Triaged
importance: Undecided → Critical
Gavin Panella (allenap) wrote :

In a subnet of 192.168.1.0/24 I was able to add a device with address 192.168.1.1 but then experienced this crash with the second device.

Blake Rouse (blake-rouse) wrote :

Looking at the code there is no reason that the interface should not be set. The only reason would because the interface did not get created. If that is the case the create with the form should raise an exception to tell the user.

Please check the following so I can see how this can be handled better:

Check that the MAC address you provided was unique. If it was not unique it should raise an exception.

Also check for any other logs that might be related to see this issue, like something in maas.log.

Changed in maas:
status: Triaged → Incomplete
Gavin Panella (allenap) wrote :

Okay, I've figured it out. If the MAC address entered in the UI has uppercase characters then get_Interface_from_list (in m.websockets.handlers.device) will not find the interface in the list.

Changed in maas:
status: Incomplete → Triaged
assignee: nobody → Gavin Panella (allenap)
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: none → 2.0.0
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers