OpenStack Compute (Nova)

virtual_interfaces extension returns UUID, Nova expects ID

Reported by Michael Fork on 2012-02-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Medium
Vish Ishaya

Bug Description

nova/api/openstack/compute/contrib/virtual_interfaces.py maps the ID as UUID:

 44 def _translate_vif_summary_view(_context, vif):
 45 """Maps keys for VIF summary view."""
 46 d = {}
 47 d['id'] = vif['uuid']
 48 d['mac_address'] = vif['address']
 49 return d

however, the the Nova code will only retrieve an ID properly.

1450 @require_context
1451 def instance_get(context, instance_id, session=None):
1452 result = _build_instance_get(context, session=session).\
1453 filter_by(id=instance_id).\
1454 first()
1455
1456 if not result:
1457 raise exception.InstanceNotFound(instance_id=instance_id)
1458
1459 return result

Resulting stack trace:

(nova.rpc): TRACE: File "/opt/stack/nova/nova/rpc/amqp.py", line 244, in _process_data
(nova.rpc): TRACE: rval = node_func(context=ctxt, **node_args)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/network/manager.py", line 236, in wrapped
(nova.rpc): TRACE: return func(self, context, *args, **kwargs)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/network/manager.py", line 1514, in get_vifs_by_instance
(nova.rpc): TRACE: vifs = self.db.virtual_interface_get_by_instance(context, instance_id)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/api.py", line 530, in virtual_interface_get_by_instance
(nova.rpc): TRACE: return IMPL.virtual_interface_get_by_instance(context, instance_id)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 119, in wrapper
(nova.rpc): TRACE: return f(*args, **kwargs)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 131, in wrapper
(nova.rpc): TRACE: db.instance_get(context, instance_id)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/api.py", line 591, in instance_get
(nova.rpc): TRACE: return IMPL.instance_get(context, instance_id)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 119, in wrapper
(nova.rpc): TRACE: return f(*args, **kwargs)
(nova.rpc): TRACE: File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 1457, in instance_get
(nova.rpc): TRACE: raise exception.InstanceNotFound(instance_id=instance_id)
(nova.rpc): TRACE: InstanceNotFound: Instance a4bf8a2b-f006-477d-8928-bbb4c92bc047 could not be found.

Is the appropriate fix to have the VIF extension return ID or to make instance_get work with UUIDs like this:

@require_context
def instance_get(context, instance_id, session=None):

    if utils.is_uuid_like(instance_id):
        result = _build_instance_get(context, session=session).\
            filter_by(uuid=instance_id).\
            first()
    else:
         result = _build_instance_get(context, session=session).\
            filter_by(id=instance_id).\
            first()

    if not result:
        raise exception.InstanceNotFound(instance_id=instance_id)

    return result

Michael Fork (mjfork) wrote :

A better fix, based on instance_update in nova/nova/db/sqlalchemy/api.py may be

@require_context
def instance_get(context, instance_id, session=None):
    if utils.is_uuid_like(instance_id):
        return instance_get_by_uuid(context, instance_id, session)
    else:
         result = _build_instance_get(context, session=session).\
            filter_by(id=instance_id).\
            first()
    if not result:
        raise exception.InstanceNotFound(instance_id=instance_id)
    return result

Changed in nova:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Vish Ishaya (vishvananda)
Michael Fork (mjfork) on 2012-02-02
Changed in nova:
assignee: Vish Ishaya (vishvananda) → Michael Fork (mjfork)

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

Changed in nova:
assignee: Michael Fork (mjfork) → Vish Ishaya (vishvananda)

Reviewed: https://review.openstack.org/3705
Committed: http://github.com/openstack/nova/commit/723cbc762a5e1d8d53e7e30223ee701dd65bd61c
Submitter: Jenkins
Branch: master

commit 723cbc762a5e1d8d53e7e30223ee701dd65bd61c
Author: Vishvananda Ishaya <email address hidden>
Date: Thu Feb 2 13:04:29 2012 -0800

    Fixes uuid lookup in virtual interfaces extension

     * Makes virtual interfaces get the instance and pass it to network.api
     * Sends the id from the instance when looking up vifs
     * Repairs the tests
     * Fixes bug 925682

    Change-Id: If25514246f30bfc983f26f7a8f1c35f33f8b9cc4

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx) on 2012-02-29
Changed in nova:
milestone: none → essex-4
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in nova:
milestone: essex-4 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers