Commit Graph

32 Commits

Author SHA1 Message Date
Brian Haley 929b383743 Fix some new pylint "R" warnings
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
2023-07-18 18:06:51 -04:00
Brian Haley cca0b3a026 Fix some pylint indentation warnings
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/services.

Trivialfix

Change-Id: Ie9779b257981bc80e69639cdaa4d7dfd0ffa5809
2022-12-01 16:21:37 +00:00
Miguel Lavalle 33de608f04 Avoid race condition when deleting trunk bridges
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
2022-11-17 10:39:30 +01:00
Slawek Kaplonski a22d6d6a95 Use ovs constants from neutron-lib
Ovs constants were moved from neutron to neutron_lib some time ago.
This patch switches to use them from neutron-lib already.

That decision was agreed during the Neutron team meeting. See [1] for
details.

[1] https://meetings.opendev.org/meetings/networking/2021/networking.2021-11-09-14.00.log.html#l-83

Requires: https://review.opendev.org/c/openstack/neutron-lib/+/834908

Change-Id: I2fd1954bec6a52856195190441d77ac8b7d97055
2022-06-17 10:36:44 +05:30
Miguel Lavalle 140bb63665 Wait longer before deleting DPDK vhu trunk bridges
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
2022-02-02 19:37:28 -06:00
Nurmatov Mamatisa db4753b6ef use payload for OVSDB_RESOURCE
This patch switches over to callback payloads for
OVSDB_RESOURCE AFTER_READ event

Change-Id: Ia7a96ff270c9defa782f02df8a58bd87c1853b52
2021-08-26 12:53:46 +00:00
Nurmatov Mamatisa 69ef824069 Use payloads for TRUNK and SUBPORTS callbacks
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
2021-04-30 14:41:08 +03:00
Nate Johnston e37722c0f5 Wait before deleting trunk bridges for DPDK vhu
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
2020-03-26 14:00:24 -04:00
Brian Haley 36727e3463 Fix pep8 errors found by hacking 2.0.0
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
2019-12-13 16:41:27 -05:00
Boden R 88cca4cabe use trunk constants from neutron-lib
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
2019-04-23 13:54:11 -06:00
Boden R ff70e20acc use neutron-lib trunk resource names
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
2019-03-25 09:59:13 -06:00
Nate Johnston bd2a1bc6c3 Do not delete trunk bridges if service port attached
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
2018-12-12 18:18:31 +00:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
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
2017-08-14 02:01:48 +00:00
Armando Migliaccio 48dbb65e8b Warn the admin of a potential OVS firewall_driver misconfiguration
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
2017-06-09 22:38:30 +00:00
Boden R 0e2b667bf1 use neutron-lib callbacks
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
2017-04-26 12:12:53 -06:00
Jenkins db2eeb9d88 Merge "Use @registry.receives in neutron.services.trunk" 2017-03-15 06:26:48 +00:00
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Cedric Brandily 20097d44bf Use @registry.receives in neutron.services.trunk
Switch to registry.receives decorator in neutron.services.trunk package.

Partial-Bug: #1668262
Change-Id: Iad3d99d958eb906b1cf2370378149ba1a4b209f4
2017-03-02 09:37:45 +00:00
Jenkins 6361c45a01 Merge "Change default exception in wait_until_true" 2017-01-12 17:32:17 +00:00
Jakub Libosvar 42cc227798 Change default exception in wait_until_true
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
2017-01-09 05:37:27 -05:00
Armando Migliaccio 9bab88ba83 Account for unwire failures during OVS trunk rewiring operations
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
2016-12-23 13:31:49 +00:00
Jenkins 3654799496 Merge "Fix misleading error trace in trunk fullstack life cycle test" 2016-10-07 11:30:55 +00:00
Armando Migliaccio 190ae4f645 Fix misleading error trace in trunk fullstack life cycle test
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
2016-09-29 14:29:24 -07:00
Armando Migliaccio 4148102f73 Process OVS trunk bridges associated to VM deletes
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
2016-09-26 23:11:22 +00:00
rossella 08f2af18f9 Handle add/remove subports events loss due to agent failures
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
2016-09-23 14:24:38 +00:00
Armando Migliaccio 29457631ad Update trunk metadata during wire/unwire operations
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
2016-09-21 22:17:04 +00:00
Armando Migliaccio 4371ae010a Ensure trunk status is acknowledged during OVS subport operations
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
2016-09-21 15:16:02 -07:00
Jenkins e2c9981669 Merge "ovsdb-handler: Follow up patch" 2016-09-13 00:04:41 +00:00
Jakub Libosvar 68d13b92a5 trunk: Remove ovs constants from trunk utils module
Trunk utils should be driver agnostic.

Change-Id: Iec646b3b11b03687013db5af6afda3a21c03acb6
Closes-Bug: 1622632
2016-09-12 18:15:21 +00:00
Jakub Libosvar a701f0901f ovsdb-handler: Follow up patch
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
2016-09-12 13:00:12 -04:00
Armando Migliaccio db1aa5fe9e Fix misnomer in _set_trunk_metadata
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
2016-09-09 10:39:23 -07:00
rossella 52300f285a OVSDBHandler for trunk ports
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
2016-09-08 22:29:37 +00:00