← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1521675] Re: n-api-meta handler could be more efficient with db

 

*** This bug is a duplicate of bug 1540526 ***
    https://bugs.launchpad.net/bugs/1540526

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

commit f8a01ccdffc13403df77148867ef3821100b5edb
Author: Hans Lindgren <hanlind@xxxxxx>
Date:   Sun Dec 20 19:27:16 2015 +0100

    Get instance security_groups from already fetched instance
    
    SecurityGroupAPI.get_instance_security_groups() takes instance.uuid as
    parameter and use that to fetch instance security groups from the db.
    Since all callers of this method has the instance to begin with we can
    use it to get security groups without the extra db call.
    
    Change-Id: I87769999839871c1a8d29c9013789d2611b8bccf
    Closes-Bug: #1521675


** Changed in: nova
       Status: In Progress => Fix Released

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1521675

Title:
  n-api-meta handler could be more efficient with db

Status in OpenStack Compute (nova):
  Fix Released

Bug description:
  The nova API metadata handler has some flows like this where it's
  getting instance metadata by the fixed IP:

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/handler.py#L88

  That leads to queries to neutron (if using neutron) to list ports by
  that fixed IP and then get the instance uuid (via device_id on the
  port) for the fixed_ip:

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/base.py#L533

  And then we get the instance object via that uuid:

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/base.py#L544

  Note we're only joining on these fields:

  expected_attrs=['ec2_ids', 'flavor', 'info_cache']

  But when constructing the InstanceMetadata object, we're loading up
  security groups separately:

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/base.py#L130

  Lazy loading 'metadata':

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/base.py#L143

  And lazy loading system_metadata:

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/base.py#L145

  https://github.com/openstack/nova/blob/7fc982e19f94a4624d54c3ac113057bed7750ec4/nova/api/metadata/password.py#L32

  We can load the metadata/system_metadata/security_groups when we get
  the instance object from the database the first time, which would
  avoid these extra queries to the database, which requires more round
  trips through to conductor.

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1521675/+subscriptions


References