Add a fixed IP to an instance failed

Bug #1294939 reported by jichenjc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
jichenjc
Juno
Fix Released
Undecided
Unassigned

Bug Description

+--------------------------------------+-------+-------------+
| ID | Label | CIDR |
+--------------------------------------+-------+-------------+
| be95de64-a2aa-42de-a522-37802cdbe133 | vmnet | 10.0.0.0/24 |
| 0fd904f5-1870-4066-8213-94038b49be2e | abc | 10.1.0.0/24 |
| 7cd88ead-fd42-4441-9182-72b3164c108d | abd | 10.2.0.0/24 |
+--------------------------------------+-------+-------------+

nova add-fixed-ip test15 0fd904f5-1870-4066-8213-94038b49be2e

failed with following logs

2014-03-19 03:29:30.546 7822 ERROR nova.openstack.common.rpc.amqp [req-fd087223-3646-4fed-b0f6-5a5cf50828eb d6779a827003465db2d3c52fe135d926 45210fba73d24dd681dc5c292c6b1e7f] Exception during message handling
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp Traceback (most recent call last):
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/openstack/common/rpc/amqp.py", line 461, in _process_data
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp **args)
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/openstack/common/rpc/dispatcher.py", line 172, in dispatch
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/network/manager.py", line 772, in add_fixed_ip_to_instance
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp self._allocate_fixed_ips(context, instance_id, host, [network])
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/network/manager.py", line 214, in _allocate_fixed_ips
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp vpn=vpn, address=address)
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/network/manager.py", line 881, in allocate_fixed_ip
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp self.quotas.rollback(context, reservations)
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp File "/usr/lib/python2.6/site-packages/nova/network/manager.py", line 859, in allocate_fixed_ip
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp 'virtual_interface_id': vif['id']}
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp TypeError: 'NoneType' object is unsubscriptable
2014-03-19 03:29:30.546 7822 TRACE nova.openstack.common.rpc.amqp

Revision history for this message
jichenjc (jichenjc) wrote :

I am not using latest code (about 1-2 month) before
but I reviewed latest code and found same logic still exist

root cause is

def allocate_fixed_ip(self, context, instance_id, network, **kwargs):

try to get an vif but it's not created yet

vif = vif_obj.VirtualInterface.get_by_instance_and_network(
                        context, instance_id, network['id'])

since objects/virtual_interface.py may return a NULL point

@base.remotable_classmethod
    def get_by_instance_and_network(cls, context, instance_uuid, network_id):
        db_vif = db.virtual_interface_get_by_instance_and_network(context,
                instance_uuid, network_id)
        if db_vif:
            return cls._from_db_object(context, cls(), db_vif)

Changed in nova:
assignee: nobody → jichencom (jichenjc)
tags: added: nova-network
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/82423

Changed in nova:
status: New → In Progress
Jay Pipes (jaypipes)
Changed in nova:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/82423
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=e08ce4de920b68c84ac45be8a657a95113688780
Submitter: Jenkins
Branch: master

commit e08ce4de920b68c84ac45be8a657a95113688780
Author: jichenjc <email address hidden>
Date: Sun Mar 23 01:49:56 2014 +0800

    Add virtual interface before add fixed IP on nova-network

    nova allow user to add fixed IP to an instance when the instance
    is running. This action will fail due to no virtual interface
    will be created before create fixed ip.
    TypeError: 'NoneType' object is unsubscriptable will be reported.

    Change-Id: I5885806d1965022816633d0105606e7aaf763b3a
    Closes-Bug: #1294939

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/142444

Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/juno)

Reviewed: https://review.openstack.org/142444
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=39097d36e447cdcf6fab2a28f356d381937f4a8b
Submitter: Jenkins
Branch: stable/juno

commit 39097d36e447cdcf6fab2a28f356d381937f4a8b
Author: jichenjc <email address hidden>
Date: Sun Mar 23 01:49:56 2014 +0800

    Add virtual interface before add fixed IP on nova-network

    nova allow user to add fixed IP to an instance when the instance
    is running. This action will fail due to no virtual interface
    will be created before create fixed ip.
    TypeError: 'NoneType' object is unsubscriptable will be reported.

    (cherry picked from commit e08ce4de920b68c84ac45be8a657a95113688780)

    Conflicts:
     nova/tests/unit/network/test_manager.py (file was moved)

    Change-Id: I5885806d1965022816633d0105606e7aaf763b3a
    Closes-Bug: #1294939

tags: added: in-stable-juno
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-1 → 2015.1.0
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.