Add a lock to prevent race during detach/attach of interface
Only allow one detach/attach at a time with the same pattern instance-port_id
in order to avoid race condition when multiple detach/attach are run
concurrently.
When multiple detach run concurrently on a specific instance-port_id,
manager consider many of them as valid because info_cache still contains
the port and info_cache is refreshed only once the first request complete.
So during this gap of time, while the first request accomplishes the task,
all subsequent requests are destined to fail and log a warning [1] in
different location of code, depending on the outcome of the first request.
The Issue is that all those caught requests finally run a
deallocate_port_for_instance which will unbind the port.
This may cause a race condition, because a successful attach can pass between
those unbind, and be silently unbound, resulting in an infrastructure/DB
inconsistency.
[1] 'Detaching interface %(mac)s failed because the device is no longer found
on the guest.'
Reviewed: https:/ /review. opendev. org/747957 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=39831c55999 abe97e3bd26a1c0 db2e4ceb467041
Committed: https:/
Submitter: Zuul
Branch: master
commit 39831c55999abe9 7e3bd26a1c0db2e 4ceb467041
Author: Alexandre Arents <email address hidden>
Date: Mon Aug 24 14:05:27 2020 +0000
Add a lock to prevent race during detach/attach of interface
Only allow one detach/attach at a time with the same pattern instance-port_id
in order to avoid race condition when multiple detach/attach are run
concurrently.
When multiple detach run concurrently on a specific instance-port_id,
manager consider many of them as valid because info_cache still contains
the port and info_cache is refreshed only once the first request complete.
So during this gap of time, while the first request accomplishes the task, port_for_ instance which will unbind the port.
all subsequent requests are destined to fail and log a warning [1] in
different location of code, depending on the outcome of the first request.
The Issue is that all those caught requests finally run a
deallocate_
This may cause a race condition, because a successful attach can pass between
those unbind, and be silently unbound, resulting in an infrastructure/DB
inconsistency.
[1] 'Detaching interface %(mac)s failed because the device is no longer found
on the guest.'
Closes-Bug: #1892870 9a6f1ba950224b0 115e466ce66
Change-Id: Iea5969d0bd16dc