neutron/neutron/agent
Rodolfo Alonso Hernandez e753dad6bf 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

Conflicts:
      neutron/agent/dhcp/agent.py
      neutron/tests/unit/agent/dhcp/test_agent.py

Change-Id: I89438feae3c0244f6da5e6a2a035d45b956ac247
(cherry picked from commit f3c229b9cc)
2021-02-10 08:52:47 +00:00
..
common [GRE] Add possibility to create GRE tunnels over IPv6 2021-01-11 11:24:14 +00:00
dhcp Process DHCP events in order if related 2021-02-10 08:52:47 +00:00
l2 Fix pep8 E128 warnings in non-test code 2019-03-12 21:22:33 +00:00
l3 Merge "Add locks for methods which sets nat rules in router" into stable/train 2021-01-23 22:00:21 +00:00
linux Fix losses of ovs flows when ovs is restarted 2021-02-05 12:10:56 +00:00
metadata Fix return correct cache when reusing port 2020-04-08 12:08:13 +00:00
ovsdb Make NeutronOvsdbIdl singleton 2020-10-21 08:37:32 +00:00
windows windows: fix terminating processes 2020-10-09 09:40:45 +00:00
__init__.py Empty files should not contain copyright or license 2014-10-20 00:50:32 +00:00
agent_extensions_manager.py Make code follow log translation guideline 2017-08-14 02:01:48 +00:00
dhcp_agent.py Enable mutable config in Neutron 2018-03-21 20:35:19 +00:00
firewall.py use EGRESS_DIRECTION and INGRESS_DIRECTION from neutron-lib 2018-02-23 10:36:36 -07:00
l3_agent.py Enable mutable config in Neutron 2018-03-21 20:35:19 +00:00
metadata_agent.py Remove deprecated cache_url 2017-11-10 00:47:19 -05:00
resource_cache.py Ignore first local port update notification 2019-07-04 12:06:11 +00:00
rpc.py Initialize modifiable list of resources in CacheBackedPluginApi. 2019-07-26 11:51:39 +00:00
securitygroups_rpc.py Add accepted egress direct flow 2020-01-28 08:33:01 +00:00