Bug 2222102 - nova should use quota_details neutron API extension when available to pre-validate port quotas available when creating a VM
Summary: nova should use quota_details neutron API extension when available to pre-val...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-nova
Version: 16.2 (Train)
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: OSP DFG:Compute
QA Contact: OSP DFG:Compute
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-11 19:28 UTC by Ihar Hrachyshka
Modified: 2023-07-19 16:49 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-07-19 16:49:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Launchpad 2027156 0 None None None 2023-07-11 19:33:50 UTC
Red Hat Issue Tracker OSP-26525 0 None None None 2023-07-11 19:29:05 UTC

Description Ihar Hrachyshka 2023-07-11 19:28:29 UTC
This bug was initially created as a copy of Bug #2219693

I am copying this bug because: while the original bug tracks potential improvements to neutron db code that fetches ports, there's no good reason for nova to fetch all project port on VM creation.

The code in https://github.com/openstack/nova/blob/master/nova/network/neutron.py#L2654 suggests that nova fetches IDs of all project ports just to count the number of ports in db and compare it to quota (to pre-validate that there's enough free ports to allocate for the request).

Instead of fetching all IDs via get_ports, nova should attempt to use quota_details API that gives ready access to info on available ports:

https://docs.openstack.org/api-ref/network/v2/?expanded=list-quotas-for-projects-with-non-default-quota-values-detail,show-quota-details-for-a-tenant-detail#quotas-details-extension-quota-details

Note that this is an API extension and was added later than the original `quota` API, so it may be that special care should be taken to accommodate to neutron-servers with no such extension.

Also, the extension seems to be controlled by the cfg.CONF.QUOTAS.quota_driver 
 config option: https://github.com/openstack/neutron/blob/6fa9142ced0eed8de9a89042747438b93de7202d/neutron/extensions/quotasv2_detail.py#L37

Which means that there may be an (upstream) configuration that would end up with quota_details API missing. So a fallback mechanism may be due.

Side note: it may be argued that neutron should not expose this config option in the first place. This bz doesn't attempt to address this request.

---

Description of problem:
vm creation is failing, problem seems related to nova getting timeout trying to retrieve tenant's ports:

2023-06-14 10:39:12.837 30 ERROR nova.api.openstack.wsgi keystoneauth1.exceptions.connection.ConnectTimeout: Request to http://$ip:9696/v2.0/ports?tenant_id=$uuid&fields=id timed out

Running openstack port list --tenant $tenant takes 1min and 50 seconds for something like 900 ports.

Version-Release number of selected component (if applicable):
RHOSP 16.1.8 witch opflex and cisco's plugins
RHOSP 16.2.5 witch opflex and cisco's plugins


How reproducible:

Steps to Reproduce:
1. find (or create) a tenant with a lot of ports from different subnets (>900 in this case)
2. try to create a vm (openstack server create --flavor xxx --image xxx --network test-net test-vm)

Actual results:
listing tenant's ports is taking something like 2 minutes, causing nova's instance creation workflow to timing out.

Expected results:
listing tenant's ports to be more efficient (referring for example to https://bugs.launchpad.net/neutron/+bug/2016704
or https://review.opendev.org/c/openstack/neutron/+/790691)

Comment 5 smooney 2023-07-19 16:49:37 UTC
We discussed this in our triage call and determined this should be treated as an RFE not a bug.
as such we have filed https://issues.redhat.com/browse/OSPRH-250 to track this as part of our
Compute Engineering Backlog. At this time we have not targeted any specific future release of OSP
but the initial development would happen as part of OSP 19 or later and then backports will be
assessed based on the final code change.

As such i am closing this bz as not a bug and future updates will be tracked in jira.


Note You need to log in before you can comment on or make changes to this bug.