After updating pylint, it started emitting additional "R"
warnings in some cases, fix some of them.
use-a-generator,
unnecessary-lambda-assignment,
consider-using-max-builtin,
consider-using-generator,
consider-using-in,
use-list-literal,
consider-using-from-import
Trivialfix
Change-Id: Ife6565cefcc30b4e8a0df9121c9454cf744225df
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/services.
Trivialfix
Change-Id: Ie9779b257981bc80e69639cdaa4d7dfd0ffa5809
Prior to this change, trunk bridges are created by os-vif but deleted
by Neutron when the last vif is removed from it. This creates race
conditions in some use cases, like DPDK with vhostuserclient mode, when
VMs are rebooted. To avoid these races, Neutron will not delete trunk
bridges anymore. Their creation and deletion will be os-vif's
responsiblity. Since [1], Nova uses the os-vif version that contains
this functionality.
This patch also changes the trunk status change event. During a live
migration, when the trunk parent port has been bound to the destination
host (that means there is only one port binding associated) and the
status has changed to ACTIVE, the method triggers the subport binding
to the new host too. This is because there could be a race condition
between the subport binding, triggered by the OVS agent, and the parent
port binding, triggered by Nova. If when the OVS agent tries to bind the
subports, the parent port is still bound to the source host, the subport
binding remains in the source host too, instead of changing to the
destination.
This patch also reverts [2] and [3]. As commented in the previous
paragraph, this patch fixes the issue reported in LP#1997025. The trunk
port live migration with ML2/OVS must be fixed with this patch.
[1]https://review.opendev.org/c/openstack/nova/+/865031
[2]https://review.opendev.org/c/openstack/neutron/+/865295
[3]https://review.opendev.org/c/openstack/neutron/+/865424
Closes-Bug: #1869244
Closes-Bug: #1997025
Change-Id: I4e16357f3ff214fcf41e418982806c24088a2665
In [1] we added a delay before deleting DPDK vhu trunk bridges to
mitigate a race condition when instances are rebooted. As explained in
[1], with DPDK rhu, a reboot is esentially a super fast bridge
delete-then-create that is prone to race conditions. We have recently
encountered in customer deployments that the wait added in [1] is not
long enough. As a consequence, this change increases the wait.
[1] https://review.opendev.org/c/openstack/neutron/+/717394
Change-Id: I5c1474b405d436d3b1e5db745d77999f1723b660
Partial-Bug: #1869244
This patch switches the code over to the payload style of callbacks [1]
for TRUNK and SUBPORTS events. As needed existing callbacks are shimmed
to support both payload and kwarg style callbacks. These shims will be
removed once all callbacks are switched over to payloads.
Also the neutron.services.trunk.callback module is removed as consumers
will no longer need the TrunkPayload therein.
NeutronLibImpact
[1]
https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html
Change-Id: Ie302b48b283f8780072b5c9e2bc8787d87c11794
DPDK vhostuser mode (DPDK/vhu) means that when an instance is powered
off the port is deleted, and when an instance is powered on a port is
created. This means a reboot is functionally a super fast
delete-then-create. Neutron trunking mode in combination with DPDK/vhu
implements a trunk bridge for each tenant, and the ports for the
instances are created as subports of that bridge. The standard way a
trunk bridge works is that when all the subports are deleted, a thread
is spawned to delete the trunk bridge, because that is an expensive and
time-consuming operation. That means that if the port in question is
the only port on the trunk on that compute node, this happens:
1. The port is deleted
2. A thread is spawned to delete the trunk
3. The port is recreated
If the trunk is deleted after #3 happens then the instance has no
networking and is inaccessible; this is the scenario that was dealt with
in a previous change [1]. But there continue to be issues with errors
"RowNotFound: Cannot find Bridge with name=tbr-XXXXXXXX-X". What is
happening in this case is that the trunk is being deleted in the middle
of the execution of #3, so that it stops existing in the middle of the
port creation logic but before the port is actually recreated.
Since this is a timing issue between two different threads it's
difficult to stamp out entirely, but I think the best way to do it is to
add a slight delay in the trunk deletion thread, just a second or two.
That will give the port time to come back online and avoid the trunk
deletion entirely.
[1] https://review.opendev.org/623275
Related-Bug: #1869244
Change-Id: I36a98fe5da85da1f3a0315dd1a470f062de6f38b
The new hacking release found some pep8 errors, fix them.
Unfortunately, moving to 2.0.0 pulled a thread with other
dependencies causing issues, so for now pin it below
1.2.0 to get the gate functioning again.
Change-Id: Ic8ee670e03dde0669231477a4209b01eb8fba7fd
The trunk constants now live in neutron-lib. This patch consumes them
by removing neutron.services.trunk.constants and using them from
neutron-lib instead.
Depends-On: https://review.opendev.org/#/c/650372/
NeutronLibImpact
Change-Id: I4445c44c7e321d0fc35976d4d855c148bb9a3b18
The trunk callback resource names now live in neutron-lib [1].
This patch switches over to use those constants from lib and they
will be removed from neutron in a later patch once consumers switch
over to lib as well.
[1] https://review.openstack.org/#/c/635209/
Change-Id: I79dfe76c1b698fe634393e469157014f1914cc8e
When a deployment has instance ports that are neutron trunk ports with
DPDK vhu in vhostuserclient mode, when the instance reboots nova will
delete the ovs port and then recreate when the host comes back from
reboot. This quick transition change can trigger a race condition that
causes the tbr trunk bridge to be deleted after the port has been
recreated. See the bug for more details.
This change mitigates the race condition by adding a check for active
service ports within the trunk port deletion function.
Change-Id: I70b9c26990e6902f8888449bfd7483c25e5bff46
Closes-Bug: #1807239
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.
Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
OVS trunks work only with OVS firewall to implement security
groups. If a trunk request is indeed processed by an OVS agent
whose firewall_driver = iptables_hybrid, we should at least
log a warning to alert the admin.
Closes-bug: #1669074
Change-Id: I60e77e60e5e6d46ceff4bff61cbc07b6534ef152
The callback modules have been available in neutron-lib since commit [1]
and are ready for consumption.
As the callback registry is implemented with a singleton manager
instance, sync complications can arise ensuring all consumers switch to
lib's implementation at the same time. Therefore this consumption has
been broken down:
1) Shim neutron's callbacks using lib's callback system and remove
existing neutron internals related to callbacks (devref, UTs, etc.).
2) Switch all neutron's callback imports over to neutron-lib's.
3) Have all sub-projects using callbacks move their imports over to use
neutron-lib's callbacks implementation.
4) Remove the callback shims in neutron-lib once sub-projects are moved
over to lib's callbacks.
5) Follow-on patches moving our existing uses of callbacks to the new
event payload model provided by neutron-lib.callback.events
This patch implements #2 from above, moving all neutron's callback
imports to use neutron-lib's callbacks.
There are also a few places in the UT code that still patch callbacks,
we can address those in step #4 which may need [2].
NeutronLibImpact
[1] fea8bb64ba7ff52632c2bd3e3298eaedf623ee4f
[2] I9966c90e3f90552b41ed84a68b19f3e540426432
Change-Id: I8dae56f0f5c009bdf3e8ebfa1b360756216ab886
By default, wait_until_true uses default exception from eventlet which
is eventlet.TimeoutError. This class is not subclass of Exception but
BaseException. In case wait_until_true times out in any test, the whole
test executor worker is stopped leaving scheduled tests not executed.
This patch replaces eventlet.TimeoutError with new WaitTimeout
exception, that inherits from Exception and thus won't break execution
of other test cases in case it's raised.
Related-Bug: 1625221
Change-Id: I44c0c22f427f61d84963e6e59393b90fbaa8f058
If a failure occurs while unwiring stale ports, we currently
ignore the outcome of the operation, whereas we should at least
warn the user that something is not quite as it is supposed
to be.
This patch makes sure that trunk status is accurately reflected
after a sequence of unwire+wire operations for a given trunk.
Closes-bug: #1649887
Change-Id: I3b6ed57e00c0146babe23ea6ed0ca14e83020d26
There is a race condition triggered by the test where a VM and subports
associated to trunk linked to the VM are deleted in fast sequence. What
happens is that subport removal can no longer store metadata associated
to the trunk as the trunk is being removed.
Even though the race does not lead to errors, the trace may mislead the
operator in thinking there is something worth investigating when in reality
everything is fine.
To solve this issue, we should avoid raising RuntimeError for when the
parent port is not found, because that prevents us from handling this
race correctly.
Related-blueprint: vlan-aware-vms
Change-Id: Ica757813fd0348235cc7b823eebf6d3588c79905
If a VM is deleted while the OVS agent is down, upon
restart the OVS trunk bridge is deleted successfully
but the patch ports integration bridge side are left
behind.
This patch makes sure the bridge as well as its peers
are cleaned up.
Closes-bug: #1623708
Change-Id: I3f010755fdb6501753d20357ad2cd0d6c02cf22a
Upon restart the agent reconciles the logical with the physical
state by removing/adding physical subports that are used to
be/are current present in the logical view.
This patch adds a functional test to demonstrate that there's
no need to handle the resync in the trunk driver, since the ovs
agent already takes care of it.
Change-Id: I164153c79313f2ae7a1fca0414736d5987656185
Partially-implements: blueprint vlan-aware-vms
Partial-bug: #1623708
Before this patch metadata on the OVS trunk bridge were
not updated during unwiring operations and upon subsequent
wire operations old subports were getting wiped from the
external_ids field of the OVS parent port. This could lead
to OVS ports left behind on the host on trunk removal.
This patch ensures that the subports stored as metadata
reflect the logical state of the trunk.
Closes-bug: #1625875
Change-Id: I9d885b10d84fad43c527d3ca7bc9a37439197fc9
Before this patch, change to trunk status was reported only when
subports were being added, but not when being removed. This patch
tweak things to make sure the same happens on subports removal.
This patch also improves unit coverage for the parts of the code
affected. In particular the import of oslo_context has been aliased
to catch errors where context as variable is shadowed by the homonym
module.
Closes-bug: #1625135
Change-Id: I73127d7829c31ca66578eb8f7d76409b36c9dc6d
Addresses handling of an error coming from OVSDB when waiting
for tap interface to appear on trunk bridge.
Removes comment that was out of sync with the code.
Adds check in handle_trunk_add routine for existence of bridge. Bridge
could have been removed concurrently by delete routine in case two OVSDB
events come very quick after each other.
Adds bridge_name to handle_trunk_remove as it's the locking key.
Partially-implements: blueprint vlan-aware-vms
Change-Id: Iae28dd8f39c10fcca6403111cafeab15b5dc3d88
Misnomer led to an AttributeError during a metadata setting.
This patch fixes the misnomer and add the missing coverage.
Change-Id: I0abcb4efd893a1c63428717feaaeaa8ffa32c59b
Partially-implements: blueprint vlan-aware-vms
Handler processes the events passed by OVSDBMonitor
and reacts to events related to trunk ports, calling
to trunk manager to wire/unwire trunks and subports.
Co-Authored-By: Jakub Libosvar <libosvar@redhat.com>
Partially-implements: blueprint vlan-aware-vms
Change-Id: I97487e9d7647b4110a2cdd48d0f129340d59a40d