Commit Graph

226 Commits

Author SHA1 Message Date
Frode Nordahl 86f51a4136
Explicitly set __tablename__ for Trunk
Without this change pylint fails with:

    neutron/objects/trunk.py:75:15: W0143: Comparing against a callable, did you omit the parenthesis? (comparison-with-callable)

Trivial-Fix
Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
Change-Id: I97f1dde896be114b81732ff74ab86a4a5be250e4
2024-02-29 11:02:31 +01:00
Bence Romsics 27601f8eea Set trunk parent port as access port in ovs to avoid loop
A non-vlan-transparent trunk parent port (tpt) should only forward
untagged frames. Earlier it was configured to forward anything (trunk
mode in ovs). This patch changes the trunk mode to access mode and
sets the trunk parent's tag explicitly to 0.

Change-Id: I4bcfe53fe87d7c9218dd0db9d7224bb323709a21
Closes-Bug: #2048785
2024-01-24 14:42:13 +01:00
Jakub Libosvar 3e6387edb8 ovn-trunk: Refactor event handling
The event registers check what type of event has happened and publish it
to the right subscriber based on it. Previously, the subscriber checked
again what type of event that is. That lead to the code double-checking
same variable. This patch removes the double-check and registers publish
the event to the correct subscriber right away.

Change-Id: Icdce95b5baffe02dbfa9320939efbfa46cb6757c
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
2023-09-28 17:11:38 -04:00
Rodolfo Alonso 1b034f8d62 Revert "[OVN][Trunk] Add port binding info on subport when parent is bound"
This reverts commit 955e621167.

Reason for revert: the port binding handling done in this patch is
incorrect and leads to issues during the cold migration process with
trunk ports in ML2/OVN.

Change-Id: Ifc2d37e2042fad43dd838821953defd99a5f8665
Closes-Bug: #2033887
2023-09-20 08:54:50 +00:00
Rodolfo Alonso 34e441e06c Revert "[OVN][Trunk] Set the subports correct host during live migration"
This reverts commit 7ed79c1f78.

Reason for revert: the port binding handling done in this patch is
incorrect and leads to issues during the cold migration process with
trunk ports in ML2/OVN.

Change-Id: I642c3eb1771463db73248a8c50c0db6f7467a6d5
Partial-Bug: #2033887
2023-09-05 10:50:35 +00:00
Rodolfo Alonso Hernandez 7ed79c1f78 [OVN][Trunk] Set the subports correct host during live migration
During the trunk migration, the parent port multiple port binding
will contain the destination host. Because this update is done
before the migration is done (in other words, the parent port
still has two port binding registers), the method setting the
binding profile of the subport will use the destination host
in advance. At the end of the live migration, the subports
host will point to the correct hostname.

Related-Bug: #2027605
Change-Id: I2370ea2f96e2e31dbd43bf232a63394388e6945f
2023-08-23 03:19:49 +00:00
Zuul 62bbfad8ff Merge "Fix some new pylint "W" warnings" 2023-08-02 11:03:07 +00:00
Brian Haley 4757b46646 Fix some new pylint "W" warnings
After updating pylint, it started emitting additional "W"
warnings in some cases, fix some of them.

  modified-iterating-list,
  implicit-str-concat,
  global-variable-not-assigned

Trivialfix

Change-Id: I7deb5f1e0aa2852cb033c78dcb4c8bc87e34be1e
2023-08-01 15:40:22 -04:00
Zuul d32c5f8f32 Merge "Fix some new pylint "R" warnings" 2023-07-28 06:58:46 +00:00
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
Rodolfo Alonso Hernandez 833a6d82cd [OVN] Prevent Trunk creation/deletion with parent port bound
This patch imitates the ML2/OVS Trunk driver behaviour. When the
trunk parent port is bound:
* A new trunk cannot be created using this parent port.
* If the port is assigned as parent port of a trunk, this
  trunk cannot be deleted.

Closes-Bug: #2022059
Change-Id: I8cfa7e67524a42224cbb4b3c3cec3cfa49b795fd
2023-06-30 14:51:27 +00:00
Arnau Verdaguer 955e621167 [OVN][Trunk] Add port binding info on subport when parent is bound
The host ID and VIF details are added on the subport when the trunk is
created, if it's created when it's not attached to any VM this fields
will remain empty and be filled on the parent port when it gets bound
to a host, but there's no callback to add this info on the subport.

Closes-Bug: #2018289
Closes-Bug: #2024160
Change-Id: I34bb6f178c314907bdf9f76789777f6736938b67
2023-06-21 15:07:54 +00:00
Rodolfo Alonso Hernandez fce516e346 [OVN] Bump the port revision number in trunk driver
When the subport binding information is updated in the OVN trunk
driver, the OVN revision number should be updated too, same as
in other ``ovn_client`` method, for example.

Closes-Bug: #2006734
Change-Id: Icda34910ea7fe308814e0cc60999b465d3540b67
2023-02-10 16:08:56 +01:00
Rodolfo Alonso Hernandez d83e243c6d [OVN] Add missing LSP device_owner info in trunk driver
The ``OVNTrunkHandler`` class updates the port binding profile of the
trunk subports. The methods ``_set_binding_profile`` and
``_unset_binding_profile`` update both the OVN LSP register and the
Neutron DB port register. This patch adds the missing field
"neutron:device_owner" from the LSP external_ids dictionary.

This patch also updates ``OvsdbNbOvnIdl.set_lswitch_port`` API method.
The method now accepts "external_ids_update" kwarg. This dictionary
allows to update (or add) individually each LSP.external_ids
dictionary key, instead of overwritting the whole variable.

NOTE: ``set_lswitch_port`` is not used outside Neutron now so this is
safe to change the API method signature.

Closes-Bug: #2006735
Change-Id: I985f3294b2ca7ab5989022ec1b904c8e29354e07
2023-02-10 15:50:56 +01:00
Rodolfo Alonso Hernandez 9401da6c7c Handle if "TRUNK_SKELETON" is not loaded
If "TRUNK_SKELETON" has not been initialized, the "unregister" method
should finish gracefully. This issue is happening in fullstalk tests,
where the trunk initialization is not executed if "trunk" is not in
the service plugins.

Closes-Bug: #2000314
Change-Id: Idef5fd8feaf1af309862d6cb3e06da3734fb6c19
2022-12-13 16:36:14 +01: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
Arnau Verdaguer 178ee6fd3d [Trunk] Update the trunk status with the parent status
After a trunk VM has been migrated the trunk status remains
DOWN, After the parent port is back to active modify the trunk
status.

Closes-Bug: #1988549
Change-Id: Ia0f7a6e8510af2c3545993e0d0d4bb06a9b70b79
2022-09-27 17:06:44 +02:00
Felix Huettner 2402145713 Cleanup fanout queues on ovs agent stop (part 2)
As a followup from the previous commit we here now also cleanup the
SubPort an Trunk fanout queues.

Closes-Bug: #1586731
Change-Id: I047603b647dec7787c2471d9edb70fa4ec599a2a
2022-09-09 09:03:45 +02: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
Rodolfo Alonso Hernandez 68bbd3586b [Trunk] Check if parent port belongs to OVN to activate
In Trunk service, the OVN was setting always the trunk to "ACTIVE"
anytime the trunk was created or updated. This patch changes this
behaviour: only when the trunk parent port belongs to OVN (that
means, there is a related logical switch port to this Neutron port),
the methods will set the trunk to "ACTIVE".

Closes-Bug: #1974183
Change-Id: Ied5ef53882d4249e0ceaa731239befdc3ba67d03
2022-05-14 09:41:25 +00:00
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
Luis Tomas Bolivar 15d6cfffc9 Ensure subports status is aligned with parent port
Subports of a trunk should have the same status as the parent port.
However, with ovn, if the parent port is in DOWN status, the subports
are transitioned to ACTIVE as soon as they are attached to the trunk.

This patch ensure the status set on the subports when being attached
matches the one on the parent port.

Closes-Bug: #1957161
Change-Id: I26c43c2909b635e8b21306ea1880da3877477a17
2022-01-24 17:55:02 +01:00
Rodolfo Alonso Hernandez e49485f2aa Replace "tenant_id" with "project_id"
Replace "tenant_id" with "project_id" in:
- Trunk service
- QoS plugin service

This is part of the remaining technical debt of the specs
https://specs.openstack.org/openstack/neutron-specs/specs/newton/moving-to-keystone-v3.html

Change-Id: I39d049bb506f24d1e1e2a35b659c93d0a22093f8
Blueprint: https://blueprints.launchpad.net/neutron/+spec/keystone-v3
2021-10-22 12:35:13 +00:00
Slawek Kaplonski b0e01c7df3 Revert "update subport status when trunk/subport create/delete is triggerred"
This reverts commit 101ccbaeb3.

Reason for revert: This commit is probably reason of some race condition
which causes random failures in the test_trunk_subport_lifecycle scenario
test.

Change-Id: Ia042384e0ac333f30235b76e50fdc8748fc2b29a
Closes-Bug: #1943708
2021-09-23 14:28:53 +00:00
Nurmatov Mamatisa ce3b86eef3 Use neutron-lib standard_attr
Now only neutron uses neutron/db/standard_attr.py
Shim can be removed

Change-Id: I980265335c5f3f6b5ee2e5fbcad9491aad91defe
2021-09-15 09:19:26 +00:00
Wenhai Li 101ccbaeb3 update subport status when trunk/subport create/delete is triggerred
When trunk or subport is created or deleted, notifications are sent. In
the meanwhile, subport status is not updated accordingly.

device_id device_owner and binding:host_id should be updated when
notifications are received.

In this patch, notifications are listened and subport status should be
updated when trunk/subport is created and subport is already added to
trunk:

    device_id: <trunk_id>
    device_owner: trunk:subport
    binding:host_id: <parent port host_id>

When trunk/subport is deleted or subport is removed from trunk, subport
status should be updated:

    device_id: None
    device_owner: None
    binding:host_id: None

Closes-Bug: #1942413
Change-Id: I0bdc5aabae0125926253b530fd0c6e79ba7bcbb9
2021-09-09 21:04:21 +08: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 21986f2be5 Remove shim in trunk/rpc/backend.py
All events use callback payloads, so can be removed

Change-Id: I36ede6028e8033228811dd9b7c27bd1a0f815f37
2021-08-23 10:29:55 +03:00
Terry Wilson 90980f496c Add wait for the post-fork event to nb/sb objects
It is possible for events from the nb/sb to fire before the opposite
db connection is made. These events can call back into driver code
which tries to access the other db before it is connected.

Closes-Bug: #1929197
Closes-Bug: #1928794
Closes-Bug: #1929633
Change-Id: If947581b90ced42981c4611c32de8f428a052c69
2021-07-13 09:23:14 -05:00
Nurmatov Mamatisa 129b823a8b use payloads for PORT AFTER_UPDATE events
This patch switches over to callback payloads for PORT
AFTER_UPDATE events.

Change-Id: I5c00eae155afa6c0fc8e3956bc39edbeca3ea1e7
2021-07-07 21:01:24 +00:00
Sebastian Lohff 31c0ef9dbe Correctly label port as SubPort in SubPortNotFound
The SubPortNotFound exception gets the port id of the subport that was
not found. This is now correctly labeled as SubPort, not as parent port
anymore.

Change-Id: I6e33ff4a7e0cb7864535a0905b5dc197a0aa8a5d
2021-06-28 17:19:41 +00:00
Slawek Kaplonski d7371e13e4 Revert "Set system_scope='all' in elevated context"
This reverts commit 062336e59b.

Now, we have proper fix for the system_scope='all' in elevated context
in the neutron-lib so we can revert temporary fix made at the end of the
Wallaby cycle.

Related-Bug: #1920001

Conflicts:
    neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
    neutron/common/utils.py
    neutron/db/address_group_db.py
    neutron/services/segments/db.py

Change-Id: Ife9b647b403bdd76a8a99984ea8858bf95c96bc3
2021-06-15 10:29:20 +02:00
Zuul df147a112e Merge "Load Linux Bridge Trunk extension if service plugin configured" 2021-06-14 13:59:51 +00:00
Rodolfo Alonso Hernandez 817d807e9d Load Linux Bridge Trunk extension if service plugin configured
Load the Linux Driver Trunk agent extension driver only if the service
plugin is enabled. If the service plugin is not enabled, the agent
extension will not subscribe to the port events.

Change-Id: I883abb5ef122ac7f8fb029d0334fa2d68893f8aa
Closes-Bug: #1930443
2021-06-11 13:26:53 +00:00
Kamil Sambor 6ada912414 Set trunk sub-port when bind profile is created
Closes-Bug: #1931583
Change-Id: Ief14ef053023a088716fa49e13d832b7e8faef31
2021-06-11 09:18:41 +02: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
Slawek Kaplonski 062336e59b Set system_scope='all' in elevated context
In case when enforce_new_defaults is set to True and new policy rules
are used, context.is_admin flag isn't really working as it was with old
rules.
But in case when elevated context is needed, it means that we need
context which has full rights to the system. So we should also set
"system_scope" parameter to "all" to be sure that system scope queries
can be done with such elevated context always.

It is needed e.g. when elevated context is used to get some data from
db. In such case we need to have db query which will not be scoped to
the single project_id and with new defaults to achieve that system_scope
has to be set to "all".

Proper fix for that should be done in neutron-lib and it is proposed
in [1] already but as we are have frozen neutron-lib version for
stable/wallaby already this patch for neutron is temporary fix for that
issue.
We can revert that patch as soon as we will be in Xena development cycle
and [1] will be merged and released.

[1] https://review.opendev.org/c/openstack/neutron-lib/+/781625

Related-Bug: #1920001
Change-Id: I0068c1de09f5c6fae5bb5cd0d6f26f451e701939
2021-03-19 12:05:56 +01:00
Zuul ecc3d81d2e Merge "Fix update of trunk subports during live migration" 2021-02-11 08:41:14 +00:00
Slawek Kaplonski e05101c8ac Fix update of trunk subports during live migration
During the live migration trunk subports where updated only based
on the "host_id" field. But when rpc message to update subports
is send trunk's port is still bound to the old host and has
"migrating_to" field in binding:profile set to the new host.
Because of that binding:host_id for the subport's port wasn't updated
proberly and port was set to DOWN on the new host.
That could even cause connectivity break if L2population is used in the
cloud.

This patch fixes that by updating subport's binding:host_id field based
on the migrating_to field if that is available and not empty.

Closes-Bug: #1914747
Change-Id: I98e55242d381ada642ca0729e9aefdea7628c945
2021-02-05 15:32:02 +01:00
Nurmatov Mamatisa 6ffeb0d623 Use constants from neutron-lib
Constants were released in neutron-lib 2.8.0

Change-Id: Iad52edda8c737585ff2fca59c032be38ba673d57
2021-02-04 06:33:49 +00:00
Oleg Bondarev e007349d47 Optimize get_ports with trunk extension
Use case: many trunk ports (300+) each with many subports.
Issue: get_ports takes much time.
Solution: apply trunk resource extend func for a full list of ports,
not for each port individually, thus avoiding a DB query for each
trunk port.

The approach will be extended for other resource extenders, like QoS,
and probably for other resources as well.
QoS: https://review.opendev.org/c/openstack/neutron/+/764454

Change-Id: Ic08e4049f6156c0700ca3c7aee251b6eb0eb97da
Closes-Bug: #1905268
2021-01-12 07:33:06 +00:00
Rodolfo Alonso Hernandez 790fff1d24 Remove "abc.abstractproperty"
"@abc.abstractproperty" is deprecated since 3.3. Now it's possible
to use "@property" on top of "@abstractmethod".

Change-Id: I0cca37b626a94a05fb983a8528c22a660e89e673
2020-11-20 16:02:07 +00:00
Slawek Kaplonski 5b4630913e Switch to new engine facade in OVN trunk driver module
Partially-Implements blueprint: enginefacade-switch

Change-Id: I998b1d0276635a00937a433586a542146488f8ab
2020-08-27 22:25:46 +02:00
Bernard Cafarelli cebdd77af8
Bump pylint version to support python 3.8
As spotted in Focal testing patch [0], pep8 test fails with many
C0321 false-positives, reported in pylint as current version does not
support python 3.8 [1]

Use a newer version of pylint and astroid, fixing or disabling some of
the new checks: no-else-*, unnecessary-comprehension, import-outside-toplevel

[0] https://review.opendev.org/#/c/738163/
[1] https://github.com/PyCQA/pylint/issues/2737

Change-Id: Ie646b7093aa8634fd950c136a0eba9adcf56591c
2020-08-06 16:00:30 +02: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
Zuul 14dd3e95ca Merge "Ensure driver error preventing trunk port deletion is logged" 2020-01-26 12:16:17 +00:00
Nate Johnston 3b56299e1f Ensure driver error preventing trunk port deletion is logged
When trunk port deletion is attempted but fails because the driver does
not permit it, the logs do not contain the driver error message that
specifies the precise rationale for preventing the trunk port deletion.
Log it explicitly.

Change-Id: I7ed1a742849dfce9e65b8eb36566112501fb0e39
2020-01-22 11:09:20 -05:00
Zuul ab24a11f13 Merge "Set binding profile directly from OVNTrunkDriver (redo cont.)" 2020-01-14 07:28:05 +00:00
Zuul e2a2995a88 Merge "Add retries to update trunk port" 2020-01-13 20:36:12 +00:00