f25cc2f503

The subnet policy rule ``ADMIN_OR_NET_OWNER_MEMBER`` requires to retrieve the network object from the database to read the project ID. When retrieving a list of subnets, this operation can slow down the API call. This patch is reordering the subnet RBAC policy checks to make this check at the end. As reported in the related LP bug, it is usual to have a "creator" project where different resources are created and then shared to others; in this case networks and subnets. All these subnets will belong to the same project. If a non-admin user from this project list all the subnets, with the code before to this patch it would be needed to retrieve all the networks to read the project ID. With the current code it is needed only to check that the user is a project reader. The following benchmark has been done in a VM running a standalone OpenStack deployment. One project has created 400 networks and 400 subnets (one per network). Each network has been shared with another project. API time to process "GET /networking/v2.0/subnets": * Without this patch: 5.5 seconds (average) * With this patch: 0.25 seconds (average) Related-Bug: #2071374 Related-Bug: #2037107 Change-Id: Ibca174213bba3c56fc18ec2732d80054ac95e859 (cherry picked from commit 729920da5e836fa7a27b1b85b3b2999146d905ba)
OpenStack Neutron
Neutron is an OpenStack project to provide "network connectivity as a service" between interface devices (e.g., vNICs) managed by other OpenStack services (e.g., Nova).
To learn more about neutron:
- Documentation: https://docs.openstack.org/neutron/latest/
- Features: https://specs.openstack.org/openstack/neutron-specs
- Defects: https://launchpad.net/neutron
- Release notes: https://docs.openstack.org/releasenotes/neutron/index.html
- Source: https://opendev.org/openstack/neutron
If you would like to contribute to Neutron, please read the file CONTRIBUTING.rst or see the Neutron contributor guide:
https://docs.openstack.org/neutron/latest/contributor/contributing.html
Get in touch via email. Use [Neutron] in your subject.
Description
Languages
Python
99.7%
Shell
0.3%