neutron: refreshing vif model for a server gets the same network multiple times

Bug #1838817 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Confirmed
Low
Unassigned
Rocky
Confirmed
Low
Unassigned
Stein
Confirmed
Low
Unassigned

Bug Description

As of this change in Rocky:

https://review.opendev.org/#/c/585339/

When refreshing the vif model for an instance, e.g. when we get a network-changed event with a specific port ID:

https://logs.opendev.org/26/674326/2/experimental/nova-osprofiler-redis/899a204/controller/logs/screen-n-cpu.txt.gz#_Aug_02_18_35_50_884613

Aug 02 18:35:50.884613 ubuntu-bionic-vexxhost-sjc1-0009723918 nova-compute[20428]: DEBUG nova.network.neutronv2.api [req-1a4c2dbf-df86-4044-a59f-f751a53c5ea6 req-b0e1e2f7-d126-4e55-909d-4803816ca80f service nova] [instance: 5bbe0419-fbeb-4667-8c56-785fdc1d0a62] Refreshing network info cache for port 252040d6-4469-46ec-88c3-85e599a43104 {{(pid=20428) _get_instance_nw_info /opt/stack/nova/nova/network/neutronv2/api.py:1756}}

We get the network for the port multiple times, first here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L2966

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L392

And then we pass that list of 1 network dict to _build_vif_model here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L2850

and pass it to _nw_info_build_network here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L2883

Which then calls _get_physnet_tunneled_info which gets the network again here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L1904

and/or here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L1928

Furthermore, when we're doing forced _heal_instance_info_cache (stein+) we'll refresh the vif model for all ports that are currently attached to the server:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L3015

And rebuild the vif model per port here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L3027

If there is more than one port on the same network attached to the server, we'll be calling show_network for each port even though we're getting the same data when those ports are on the same network.

I noticed this while checking some osprofiler results and noticed the network-changed event on the port-targeted refresh took a relatively long time:

https://logs.opendev.org/26/674326/2/experimental/nova-osprofiler-redis/899a204/osprofiler-traces/trace-fc50ca23-a6c2-474a-ac07-e61e706eb27d.html.gz

Matt Riedemann (mriedem)
Changed in nova:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
Matt Riedemann (mriedem) wrote :

There are similar inefficiencies here:

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L2014

https://github.com/openstack/nova/blob/600ecf3d9a5116d040cd18023ff270b91b06247d/nova/network/neutronv2/api.py#L2031

The former in the case we have multiple ports on the same network, the latter if we have a server create request with multiple instances of the same network (the user is telling nova to create multiple ports on the same network).

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

Fix proposed to branch: master
Review: https://review.opendev.org/674422

Changed in nova:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Matt Riedemann (<email address hidden>) on branch: master
Review: https://review.opendev.org/674422
Reason: I'm no longer working on this. There are some ideas in the comments to simplify but someone else would have to take that on.

Matt Riedemann (mriedem)
Changed in nova:
assignee: Matt Riedemann (mriedem) → nobody
importance: Medium → Low
status: In Progress → Confirmed
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.