Reviewed: https://review.openstack.org/245677 Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=4f75ba6729366f87624554e7732ef122c6ebac4b Submitter: Jenkins Branch: master
commit 4f75ba6729366f87624554e7732ef122c6ebac4b Author: Sergey Nikitin <[email protected]> Date: Mon Nov 16 12:39:36 2015 +0300 Changed filter_by() to filter() during filtering instances in db API When we use filter_by() fields for filtering are extracted from the primary entity of the query, or the last entity that was the target of a call to Query.join(). If db query contains filters 'project_id' and 'tags' (or 'tags-any') db error will be raised: Entity '<AliasedClass at 0x7fb09ba18b50; Tag>' has no property 'project_id' It happens because we use join(models.Tag) to filter instances by tags. Sqlalchemy try to find 'project_id' field in Tag model. To fix this issue we should use filter() instead of filter_by(). filter() works fine with join(). Closes-Bug: #1516546 Change-Id: Ibcac2a08aa51f698c690399f65c77130ff2de173 ** 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/1516546 Title: Tag has no property 'project_id' during filtering by tags Status in OpenStack Compute (nova): Fix Released Bug description: When we use filter_by() fields for filtering are extracted from the primary entity of the query, or the last entity that was the target of a call to Query.join(). If db query contains filters 'project_id' and 'tag' (or 'tag-any') db error will be raised: File "nova/db/api.py", line 677, in instance_get_all_by_filters use_slave=use_slave) File "nova/db/sqlalchemy/api.py", line 204, in wrapper return f(*args, **kwargs) File "nova/db/sqlalchemy/api.py", line 1877, in instance_get_all_by_filters sort_dirs=[sort_dir]) File "nova/db/sqlalchemy/api.py", line 204, in wrapper return f(*args, **kwargs) File "nova/db/sqlalchemy/api.py", line 2046, in instance_get_all_by_filters_sort filters, exact_match_filter_names) File "nova/db/sqlalchemy/api.py", line 2220, in _exact_instance_filter query = query.filter_by(**filter_dict) File "/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 1345, in filter_by for key, value in kwargs.items()] File "/opt/stack/nova/.tox/py27/local/lib/python2.7/site-packages/sqlalchemy/orm/base.py", line 383, in _entity_descriptor (description, key) sqlalchemy.exc.InvalidRequestError: Entity '<AliasedClass at 0x7fb09ba18b50; Tag>' has no property 'project_id' It happens because we use join(models.Tag) to filter instances by tags. Sqlalchemy try to find 'project_id' field in Tag model. To fix this issue we should use filter() instead of filter_by(). filter() work fine with join(). To manage notifications about this bug go to: https://bugs.launchpad.net/nova/+bug/1516546/+subscriptions -- Mailing list: https://launchpad.net/~yahoo-eng-team Post to : [email protected] Unsubscribe : https://launchpad.net/~yahoo-eng-team More help : https://help.launchpad.net/ListHelp

