query resource with some filter return 500 error

Bug #1654195 reported by zhaobo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Low
zhaobo

Bug Description

Use restAPI to query resource with the filter key like our base db model attributes. It will hit internel error. As the api layer not stop these kind values to db layer. The process will take these values to query the resource in db.

GET /v2.0/networks?__contains__=1

2017-01-05 11:59:26.592 ERROR neutron.api.v2.resource [req-be7a2100-f0e2-4604-abfa-63f290b08719 admin a4d7fafd8b6e42f5aa1de690e360d285] index failed: No details.
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource Traceback (most recent call last):
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/resource.py", line 79, in resource
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource result = method(request=request, **args)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 92, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource setattr(e, '_RETRY_EXCEEDED', True)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 88, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 151, in wrapper
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource ectxt.value = e.inner_exc
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 139, in wrapper
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 128, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource traceback.format_exc())
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 123, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*dup_args, **dup_kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 369, in index
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return self._items(request, True, parent_id)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/api/v2/base.py", line 308, in _items
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource obj_list = obj_getter(request.context, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 163, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return method(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 92, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource setattr(e, '_RETRY_EXCEEDED', True)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 88, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 151, in wrapper
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource ectxt.value = e.inner_exc
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_db/api.py", line 139, in wrapper
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 128, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource traceback.format_exc())
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 220, in __exit__
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource self.force_reraise()
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/usr/local/lib/python2.7/dist-packages/oslo_utils/excutils.py", line 196, in force_reraise
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource six.reraise(self.type_, self.value, self.tb)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 123, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return f(*dup_args, **dup_kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 856, in get_networks
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource limit, marker, page_reverse)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/api.py", line 163, in wrapped
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource return method(*args, **kwargs)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 442, in get_networks
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource page_reverse=page_reverse)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/common_db_mixin.py", line 238, in _get_collection
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource page_reverse=page_reverse)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/common_db_mixin.py", line 221, in _get_collection_query
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource context)
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource File "/opt/stack/neutron/neutron/db/common_db_mixin.py", line 156, in _apply_filters_to_query
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource query = query.filter(column.in_(value))
2017-01-05 11:59:26.592 TRACE neutron.api.v2.resource AttributeError: 'function' object has no attribute 'in_'

zhaobo (zhaobo6)
Changed in neutron:
assignee: nobody → zhaobo (zhaobo6)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

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

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/416932
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=22707fb3d2a621d2f632f395f8d77c3f9e83c90d
Submitter: Jenkins
Branch: master

commit 22707fb3d2a621d2f632f395f8d77c3f9e83c90d
Author: ZhaoBo <email address hidden>
Date: Thu Jan 5 17:36:18 2017 +0800

    Add filter check for quering

    Neutron rasises 500 error if the filter is the resources'
    object property.

    This patch add the check to prevent querying with base_db property.

    Change-Id: I1aec4c1537e687e9087c468a592802779f370cb3
    Closes-Bug: #1654195

Changed in neutron:
status: In Progress → Fix Released
tags: added: neutron-proactive-backport-potential
Changed in neutron:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/422058

tags: removed: neutron-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/newton)

Reviewed: https://review.openstack.org/422058
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=a1a0c911ec8d7ac8d47ab19baac2a56548855dd8
Submitter: Jenkins
Branch: stable/newton

commit a1a0c911ec8d7ac8d47ab19baac2a56548855dd8
Author: ZhaoBo <email address hidden>
Date: Thu Jan 5 17:36:18 2017 +0800

    Add filter check for quering

    Neutron rasises 500 error if the filter is the resources'
    object property.

    This patch add the check to prevent querying with base_db property.

    Change-Id: I1aec4c1537e687e9087c468a592802779f370cb3
    Closes-Bug: #1654195
    (cherry picked from commit 22707fb3d2a621d2f632f395f8d77c3f9e83c90d)

tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 10.0.0.0b3

This issue was fixed in the openstack/neutron 10.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 9.2.0

This issue was fixed in the openstack/neutron 9.2.0 release.

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.