Consistency groups API is always returning context.project_id groups from cinder.groups table

Bug #1671220 reported by prashkre
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
prashkre

Bug Description

Irrespective of passing the request parameters 'all_tenants', 'project_id' to filter the results, consistency groups GET API is always getting context.project_id consistency groups from cinder.groups table.

More information on the issue is explained here:

consistency groups GET API [0] is fetching consistency groups from cinder.consistencygroups(line 137) and cinder.groups(line 141) tables at [1]

Suppose lets consider context.project_id is 'proj1' and we pass the filters as {'all_tenants': True, 'project_id': 'proj2'} to get consistency groups from 'proj2'. In the flow at [2] it is deleting "all_tenants" parameter from filter when getting groups from cinder.consistencygroups table and while getting consistencygroups from cinder.groups table it is going to else block to get context.project_id i.e. proj1 groups.

[0] https://developer.openstack.org/api-ref/block-storage/v2/index.html?expanded=list-consistency-groups-with-details-detail#consistency-groups
[1] https://github.com/openstack/cinder/blob/master/cinder/api/contrib/consistencygroups.py#L130.
[2] https://github.com/openstack/cinder/blob/master/cinder/consistencygroup/api.py#
[3] https://github.com/openstack/cinder/blob/master/cinder/group/api.py#L774

Revision history for this message
wangxiyuan (wangxiyuan) wrote :

Can't reproduce. Can you make sure that the "proj1" is admin?
if it's admin, the logic can't go to "else" in https://github.com/openstack/cinder/blob/master/cinder/group/api.py#L774

non-admin users can't use all-tenants filter

Revision history for this message
prashkre (prashkre) wrote :

wangxiyuan, I have reproduced this issue with user as admin in proj1. If we look at lines [0], [1] same 'filters' object is being used at both places and this 'filters' object is updated on call from [0] to [2] by deleting 'all_tenants' entry from it. So when a call is made from [1] to [3] in the next flow, it doesn't have 'all_tenants' in filters even though user is admin then execution goes to else block at [4].

[0] https://github.com/openstack/cinder/blob/master/cinder/api/contrib/consistencygroups.py#L138
[1] https://github.com/openstack/cinder/blob/master/cinder/api/contrib/consistencygroups.py#L142

[2] https://github.com/openstack/cinder/blob/master/cinder/consistencygroup/api.py#L711
[3] https://github.com/openstack/cinder/blob/master/cinder/group/api.py#L760
[4] https://github.com/openstack/cinder/blob/master/cinder/group/api.py#L774

prashkre (prashkre)
Changed in cinder:
assignee: nobody → prashkre (prashkre)
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/446199

Changed in cinder:
status: New → In Progress
Revision history for this message
wangxiyuan (wangxiyuan) wrote :

Yeah, I can the point now. Thanks

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

Reviewed: https://review.openstack.org/446199
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=9ed8c61ec5745f7e07e7eb78888e3e76fcd5b289
Submitter: Jenkins
Branch: master

commit 9ed8c61ec5745f7e07e7eb78888e3e76fcd5b289
Author: prashkre <email address hidden>
Date: Wed Mar 15 17:28:57 2017 -0400

    Consistency groups API is not returning project_id filter groups.

    This fixes issue with consistency groups API which is always
    returning 'context.project_id' specific consistency groups from
    cinder.groups instead of required project specific groups i.e.
    irrespective of filters ('all_tenants','project_id') being passed
    it is returning context.project_id groups.

    Closes-Bug: #1671220

    Change-Id: I553aab33c01f1e5b0053172e86d276ccfabf4952

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

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/448379

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/ocata)

Reviewed: https://review.openstack.org/448379
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=25a1805b198080425e9244d7dcc79e81dd9d024f
Submitter: Jenkins
Branch: stable/ocata

commit 25a1805b198080425e9244d7dcc79e81dd9d024f
Author: prashkre <email address hidden>
Date: Wed Mar 15 17:28:57 2017 -0400

    Consistency groups API is not returning project_id filter groups.

    This fixes issue with consistency groups API which is always
    returning 'context.project_id' specific consistency groups from
    cinder.groups instead of required project specific groups i.e.
    irrespective of filters ('all_tenants','project_id') being passed
    it is returning context.project_id groups.

    Closes-Bug: #1671220

    Change-Id: I553aab33c01f1e5b0053172e86d276ccfabf4952
    (cherry picked from commit 9ed8c61ec5745f7e07e7eb78888e3e76fcd5b289)

tags: added: in-stable-ocata
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 10.0.1

This issue was fixed in the openstack/cinder 10.0.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 11.0.0.0b1

This issue was fixed in the openstack/cinder 11.0.0.0b1 development milestone.

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.