← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1516546] [NEW] Tag has no property 'project_id' during filtering by tags

 

Public bug reported:

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().

** Affects: nova
     Importance: Medium
     Assignee: Sergey Nikitin (snikitin)
         Status: In Progress

-- 
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):
  In Progress

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


Follow ups