neutron/neutron/api
Rodolfo Alonso Hernandez dc01f5b330 Process DHCP events in order if related
When processing port events (create, update, delete), the port
provisioning (port creation) has priority over the other events [1].
As reported in the related bug, if a port deletion with an IP
address and another port creation with the same IP address arrive
to the DHCP agent, those events can be processed in the same queue.

Because of the creation event priority, even when this event arrived
after the deletion event, it will be processed first. That will
clash with the DHCP agent cache, that contains a port (not deleted
yet) with the same IP address. That will trigger an unwanted resync.

This patch implements a specific logic to store the events in
"ResourceProcessingQueue" (that uses "PriorityQueue" [2]). When
a port event arrives, the event comparison method checks the
(subnet, fixed_ips) tuple set of both elements. If there is a
coincidence, that means those ports are the same or are using
the same IP addreses (the race condition explained in the bug).
In this case, the priority is defined only by the timestamp;
that means the events are processed in order of arrival.

Because the Neutron server do not allow to have two ports in the
same subnet with the same IP address, the order of the events is
guaranteed. In the case explained in the bug, the deletion event
will be processed first.

[1]https://review.opendev.org/c/openstack/neutron/+/626830
[2]https://docs.python.org/3/library/queue.html#queue.PriorityQueue

Closes-Bug: #1913723

Change-Id: I89438feae3c0244f6da5e6a2a035d45b956ac247
2021-02-07 10:05:32 +00:00
..
rpc Process DHCP events in order if related 2021-02-07 10:05:32 +00:00
v2 Add base support for update_port_bulk 2019-07-05 21:07:29 +00:00
views Add a new configuration variable for api links. 2017-04-18 15:16:41 +00:00
__init__.py Added API extensions to detect sorting/pagination features 2016-08-01 22:57:15 +02:00
api_common.py Fix bug: AttributeError arises while sorting with standard attributes 2019-05-29 17:58:51 +08:00
extensions.py remove neutron.common.exceptions 2019-02-01 14:35:00 -07:00