The volume_image_metadata field is missing from volume list

Bug #1337526 reported by Mathieu Gagné
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Mathieu Gagné
Icehouse
Fix Released
Undecided
Mathieu Gagné

Bug Description

When listing all volumes, the field volume_image_metadata is missing from the response.

When enabling debug, this error is logged:

Problem retrieving volume image metadata. It will be skipped. Error: Entity '<class 'cinder.db.sqlalchemy.models.VolumeGlanceMetadata'>' has no property 'project_id' _get_all_images_metadata /usr/lib/python2.7/dist-packages/cinder/api/contrib/volume_image_metadata.py:43

If code is updated to log the whole traceback instead, this can be found:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cinder/api/contrib/volume_image_metadata.py", line 39, in _get_all_images_metadata
    all_metadata = self.volume_api.get_volumes_image_metadata(context)
  File "/usr/lib/python2.7/dist-packages/cinder/volume/api.py", line 686, in get_volumes_image_metadata
    db_data = self.db.volume_glance_metadata_get_all(context)
  File "/usr/lib/python2.7/dist-packages/cinder/db/api.py", line 552, in volume_glance_metadata_get_all
    return IMPL.volume_glance_metadata_get_all(context)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/api.py", line 137, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/api.py", line 2447, in volume_glance_metadata_get_all
    return _volume_glance_metadata_get_all(context)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/api.py", line 137, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/api.py", line 2436, in _volume_glance_metadata_get_all
    session=session).\
  File "/usr/lib/python2.7/dist-packages/cinder/db/sqlalchemy/api.py", line 195, in model_query
    query = query.filter_by(project_id=context.project_id)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 1249, in filter_by
    for key, value in kwargs.iteritems()]
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/util.py", line 1218, in _entity_descriptor
    (description, key)
InvalidRequestError: Entity '<class 'cinder.db.sqlalchemy.models.VolumeGlanceMetadata'>' has no property 'project_id'

The problem is caused by a filtering done on project_id.

VolumeGlanceMetadata does not have the project_id field, filtering should be done on the Volume associated to the VolumeGlanceMetadata instead.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

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

Changed in cinder:
assignee: nobody → Mathieu Gagné (mgagne)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/104662
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=06dd7f28d1d3ec8619df0d25ddfe977d538897b3
Submitter: Jenkins
Branch: master

commit 06dd7f28d1d3ec8619df0d25ddfe977d538897b3
Author: Mathieu Gagné <email address hidden>
Date: Thu Jul 3 15:30:05 2014 -0400

    volume_image_metadata missing from volume list

    The volume_image_metadata field was missing from the volume list
    because we tried to filter VolumeGlanceMetadata against a non-existent
    project_id field. Filtering should be done on the Volume associated
    to the VolumeGlanceMetadata instead.

    Move project_id filtering out of model_query as it assumes
    the project_id field is in the queried model itself.
    Build the filter ourselves against Volume.

    Change-Id: I6053708296f2b5e24513dc87ed63da0f67c220ae
    Closes-bug: #1337526

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

Fix proposed to branch: stable/icehouse
Review: https://review.openstack.org/106238

Mathieu Gagné (mgagne)
tags: added: icehouse-backport-potential
Changed in cinder:
milestone: none → juno-2
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/icehouse)

Reviewed: https://review.openstack.org/106238
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=ce35e7a2558d5b62617616c3ec930c79213186d6
Submitter: Jenkins
Branch: stable/icehouse

commit ce35e7a2558d5b62617616c3ec930c79213186d6
Author: Mathieu Gagné <email address hidden>
Date: Thu Jul 3 15:30:05 2014 -0400

    volume_image_metadata missing from volume list

    The volume_image_metadata field was missing from the volume list
    because we tried to filter VolumeGlanceMetadata against a non-existent
    project_id field. Filtering should be done on the Volume associated
    to the VolumeGlanceMetadata instead.

    Move project_id filtering out of model_query as it assumes
    the project_id field is in the queried model itself.
    Build the filter ourselves against Volume.

    Fix glance metadata SQL query performance

    The query built to retrieve glance metadata associated to a volume
    was sub-optimal: all rows of volume_glance_metadata were returned.

    Fix it by properly joining the 2 tables with volume_id field.

    Closes-bug: #1337526
    Closes-bug: #1349936
    Change-Id: I6053708296f2b5e24513dc87ed63da0f67c220ae
    (cherry picked from commit 06dd7f28d1d3ec8619df0d25ddfe977d538897b3)
    (cherry picked from commit 8f8a8a6ffe14cf7bb461dc26d178bf8acc8ddf12)

tags: added: in-stable-icehouse
Thierry Carrez (ttx)
Changed in cinder:
milestone: juno-2 → 2014.2
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.