]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commit
Add volume_type to volume object expected_attrs
authorMichał Dulko <michal.dulko@intel.com>
Wed, 9 Mar 2016 15:04:20 +0000 (16:04 +0100)
committerMichał Dulko <michal.dulko@intel.com>
Thu, 10 Mar 2016 13:11:02 +0000 (14:11 +0100)
commit4e3f61b331db1a4d97198ee485ccd4498091ce82
tree03ec5a1b6b052dc2cb4a1d319a865544f25943b3
parent08b74ce3280f66613e9cae8bce3d00c20d38aff2
Add volume_type to volume object expected_attrs

We haven't had volume_type in expected_attrs for volume objects lists.
This resulted in situation in which although we were joining the
volume_type explicitely in DB API, the object just dropped the data.
Volume type was then lazy loaded when needed, so every "cinder list"
call was making additional DB queries per returned volume, causing
massive performance drop.

Actually there were two unnecessary DB calls per volume, because not
only volume_type was fetched, but also volume_type.extra_specs as a result
of passing 'extra_specs' in expected_attrs when calling
VolumeType._from_db_volume in Volume._from_db_volume (wow, that's
complicated…).

This commit sorts this out by adding volume_type to expected_attrs to
match what we join in the DB. Please note that I'm not adding
consistencygroup and volume_attachment on purpose - addition causes some
unit tests failure and that late in the release it seems risky to try
fixing that. The changes also required minor rework of expected_attrs
infrastructure in the o.vo layer to be able to pass different values
when we query for just a single volume and when we fetch whole list (as
we're doing different joins in the DB layer in both cases).

Change-Id: Iabf9c3fab56ffef50695ce45745f193273822b39
Closes-Bug: 1555153
cinder/objects/base.py
cinder/objects/snapshot.py
cinder/objects/volume.py
cinder/objects/volume_type.py
cinder/tests/unit/api/contrib/test_volume_actions.py
cinder/tests/unit/api/v2/stubs.py