[trunk] maasserver.models.interface.MultipleObjectsReturned: Got more than one item.

Bug #1485584 reported by Andres Rodriguez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Blake Rouse

Bug Description

When trying to deploy a node, the following error is shown in the UI:

maasserver.models.interface.MultipleObjectsReturned: Got more than one item.

The regiond.log shows:

2015-08-17 20:32:00 [-] Error on request (120) node.action: Got more than one item. [11/1144]
        Traceback (most recent call last):
          File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
            self.__bootstrap_inner()
          File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
            self.run()
          File "/usr/lib/python2.7/threading.py", line 763, in run
            self.__target(*self.__args, **self.__kwargs)
        --- <exception caught here> ---
          File "/usr/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 191, in _worker
            result = context.call(ctx, function, *args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 425, in call_within_transaction
            return func_outside_txn(*args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 301, in retrier
            return func(*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/provisioningserver/utils/twisted.py", line 158, in wrapper
            return func(*args, **kwargs)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 420, in call_within_transaction
            return func_within_txn(*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/maasserver/websockets/base.py", line 332, in execute
            return m(params)
          File "/usr/lib/python2.7/dist-packages/maasserver/websockets/handlers/node.py", line 519, in action
            return action.execute(**extra_params)
          File "/usr/lib/python2.7/dist-packages/maasserver/node_action.py", line 317, in execute
            self.node.start(self.user)
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 420, in call_within_transaction
            return func_within_txn(*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/maasserver/models/node.py", line 2162, in start
            update_host_maps=update_host_maps)
          File "/usr/lib/python2.7/dist-packages/maasserver/models/node.py", line 1951, in claim_static_ip_addresses
            update_host_maps=update_host_maps)
          File "/usr/lib/python2.7/dist-packages/maasserver/models/macaddress.py", line 331, in claim_static_ips
            interface = get_one(PhysicalInterface.objects.filter(mac=self))
          File "/usr/lib/python2.7/dist-packages/maasserver/utils/orm.py", line 97, in get_one
            raise get_exception_class(items)("Got more than one item.")
        maasserver.models.interface.MultipleObjectsReturned: Got more than one item.

Related branches

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Looking at it myself, I found this out:

On /usr/lib/python2.7/dist-packages/maasserver/models/macaddress.py line 331, I changed:

interface = get_one(PhysicalInterface.objects.filter(mac=self))

For

interface = PhysicalInterface.objects.filter(mac=self)

And trying to reploy, I'd get (on regiond.log):
            update_host_maps=update_host_maps)
          File "/usr/lib/python2.7/dist-packages/maasserver/models/macaddress.py", line 334, in claim_static_ips
            return interface.claim_static_ips(
        exceptions.AttributeError: 'QuerySet' object has no attribute 'claim_static_ips'

and on maas.log:

Aug 17 20:34:17 trusty-maas9 maas.macaddress: [ERROR] [<PhysicalInterface: name=eth0, type=physical, mac=74:d4:35:89:b9:cd>, <PhysicalInterface:
 name=eth0, type=physical, mac=74:d4:35:89:b9:cd>, <PhysicalInterface: name=eth0, type=physical, mac=74:d4:35:89:b9:cd>, <PhysicalInterface: nam
e=eth0, type=physical, mac=74:d4:35:89:b9:cd>]

The big question, why would it return multiple eth0's since there's only one interface per node, or per that specific mac.

summary: - maasserver.models.interface.MultipleObjectsReturned: Got more than one
- item.
+ [trunk] maasserver.models.interface.MultipleObjectsReturned: Got more
+ than one item.
Changed in maas:
milestone: none → 1.9.0
importance: Undecided → Critical
assignee: nobody → Mike Pontillo (mpontillo)
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Oh added: maaslog.error(interface) to get the log

Revision history for this message
Andres Rodriguez (andreserl) wrote :

I fiddled around with the node a little bit, and did the following in the code (line 330)

        interface = PhysicalInterface.objects.filter(mac=self)
        maaslog.error(interface[0])
        return interface[0].claim_static_ips(
            alloc_type, requested_address, fabric, user, update_host_maps)

Revision history for this message
Andres Rodriguez (andreserl) wrote :

A extra comment in #3. I had machines that were in Ready state and had a static IP address allocated. After perfroming the work around on #3, the machine ended up having 2 static NIC's rather than only just one

Changed in maas:
status: New → Triaged
assignee: Mike Pontillo (mpontillo) → Blake Rouse (blake-rouse)
status: Triaged → 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.