32 Commits

Author SHA1 Message Date
Flavio Fernandes
e5699cf86b Add integration tests with port forwarding
Floating IP port forwarding by ml2/ovn uses OVN load balancers.
Integration tests with ovn_octavia_provider here are done to
ensure that these two functionalities can coexist.

Depends-On: https://review.opendev.org/#/c/741303/
Change-Id: I4b5ded003cbb3c9c4c0bc026f0e9b396f2665531
2020-09-16 16:11:46 +00:00
Maciej Józefczyk
57dbca6c5e Fix member_batch_update function to follow api v2
The member_batch_update function signature was missing
pool_id parameter. [1]

[1] https://docs.openstack.org/octavia/latest/contributor/guides/providers.html

Change-Id: I0ac14de29ff92416f103c880bcdc28dd76e00865
Closes-Bug: 1888489
2020-07-22 12:30:03 +00:00
Zuul
e4f6b8ff8d Merge "Add a hacking check for importing mock library" 2020-07-14 13:48:50 +00:00
Brian Haley
6ed2660676 Add a hacking check for importing mock library
We should only be using unittest.mock since we're python3-only,
so add and enable a hacking check that will catch it.

Change-Id: I64847f329ee3e1a3377a8c63df90c697d8b74c86
2020-06-09 14:46:36 -04:00
Maciej Jozefczyk
ac4d0272a8 Do not send status update in case of IpAddressAlreadyAllocated
If IpAddressAlreadyAllocated is raised and the created VIP with
the same IP address allocated is not owned by LB that we're trying
to create, we should raise DriverError instead passing the status
update to Octavia API.

Change-Id: Id0dc8a478b903b80cf8afdfa3d2b23e90d22e112
Closes-Bug: 1882724
2020-06-09 15:52:25 +00:00
Terry Wilson
28c311ccd7 Fix the Backend class for ovsbapp index changes
The Backend class in ovsdbapp was modified when adding index
support. Different projects wanted different scopes for their
ovsdb_connections, and this was moved to a property in ovsdbapp.
For now, we can just set ovsdb_connection = None on the backend
class to get the behavior we desire.

Also mocks out autocreate_indicies for a unit test.

Change-Id: I7741a441a55e67354bc0887e5db2f8137073b5b4
2020-06-09 10:14:49 -05:00
Maciej Józefczyk
23d743a444 Add support for OVN LB selection fields
Prior this patch OVN Octavia provider driver used
default 5-tuple-hash algorithm which is pretty similar to
SOURCE_IP_PORT.

Unfornutelly because of the bug described here [1] it
was not clear how 5-tuple-hash works and some inconsistencies
between kernel and user space implementations were found.

OVN recently added support for selective fields in OVN LB, to
explicitly define what fields are being hashed to tackle this problem.

This commit adds support for that kind of hashing. If installation
of OVN on which OVN Octavia provider is running doesn't support
selective fields - it will use old behavior.

[1] https://mail.openvswitch.org/pipermail/ovs-discuss/2020-April/049896.html
[2] 5af304e747


Change-Id: I7b4ab99d1be2855e18b186557990c85f170ad548
Closes-Bug: #1871239
2020-05-14 09:38:12 +00:00
Brian Haley
90cd9ba1e6 Re-home ovsdb event classes
Placing in a separate file allows the agent code to no
longer import any driver code.

Change-Id: Ibccf64cb77902d39f286f00a35875a50b41bab3e
2020-05-12 11:06:36 +00:00
Brian Haley
b1a457f35f Re-home unit tests
Move them to their respective test_*.py files.

Created base.py to hold the parent class common to all
sub-tests.

Change-Id: I4f8466ceb36356e0d80cdcfe1e6e2c5884c1f567
2020-05-12 11:06:14 +00:00
Brian Haley
178dbd3fee Re-home OvnProviderHelper class
Put it in a separate file from the driver class.

Change-Id: I32eda38d212b7b5a1434d9130a1b4e268d2c3aa9
2020-05-12 11:06:05 +00:00
Brian Haley
fd460cd0fa Re-home get_neutron_client() into common/clients.py
Move in preparation for re-homing OvnProviderHelper class.

Change-Id: Idc627fd1c74637d59c47f1e8989cf0bdfa3bb75f
2020-05-06 16:47:37 -04:00
Brian Haley
5685895a1a Re-home constants to common/constants.py
Move in preparation for re-homing OvnProviderHelper class.

Change-Id: If972469964ae907b048446bd15ba2661aa50f266
2020-04-30 18:23:48 +00:00
Brian Haley
21701b03d0 Re-home OvnNbIdlForLb class
Seems like it should live with the other ovsdb code in
ovsdb/impl_idl_ovn.py

Change-Id: Idee498bc0104533dd58b9b9a82523986a241ec05
2020-04-30 14:20:20 -04:00
Brian Haley
94daec2d4a Re-home MockedLB to tests.unit.fakes
Renamed to tests.unit.fakes.FakeLB

Change-Id: I1d18634f48c29ab3c07c244cc8826bdb987afdc4
2020-04-27 16:39:40 -04:00
Brian Haley
c6cee92073 Spawn long-running processes in the driver agent
The OVN Octavia provider driver in the OvnProviderHelper
class caches these attributes:

    ovn_nbdb_api_for_events
    ovn_nb_idl_for_events
    ovn_nbdb_api

to not re-create things each time OVN IDL that is used for
handling events is called.

We should be using the Octavia Driver Provider Agent framework
instead to not have those long-running IDLs in the API process.

This change:
- Creates driver provider agent and registers its entry point
- While setting up the driver agent instance, start IDL that
  will handle events
- Stop caching ovn_nbdb_api, ovn_nb_idl_for_events and
  ovn_nbdb_api_for_events in the OvnProviderHelper class

Change-Id: I0034a48997bd6b95e1b51bfcbd56e8372b35e62f
Closes-bug: #1871355
2020-04-23 11:03:36 -04:00
Brian Haley
eb1e24ac46 Improve test coverage
Added a number of unit tests based on coverage report
data, it's up to 79% now.

Fixed test_pool_create_exception() to call pool_create()
instead of pool_update().

Also fixed a bug in the driver.pool_update() exception code
path found when adding a new test, status['pools'] is the
correct element.

Change-Id: Ic72aad21e0ecf5b0334b321b18515d909daa3ba4
2020-04-03 12:48:46 -04:00
Zuul
bbb1755176 Merge "Remove the dependency on the "mock" package" 2020-04-03 11:13:07 +00:00
Zuul
838f9d6d34 Merge "Remove backwards-compatibility check" 2020-04-03 10:59:11 +00:00
Brian Haley
88ea5cf828 Remove the dependency on the "mock" package
This repo is python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock".

Fixed one related functional test failure.

Change-Id: I4f7568b1af254488cbc75aefac2a1708e70eaf31
2020-04-02 17:36:25 -04:00
Brian Haley
c78aa81e7d Update hacking for Python3
The repo is Python 3, so update hacking to version 3.0 which
supports Python 3.

Update local hacking checks for new flake8.

Change-Id: I37851c466ac14f41506f3d0d7cee75db84580756
2020-03-31 19:44:32 -04:00
Maciej Józefczyk
40545dc9b5 Stop using Octavia network driver
We shouldn't be using Octavia components except octavia-lib
in provider driver.
For now we only use Neutron client methods from Octavia Neutron network
driver, so this patch removes use of Octavia network driver
in favor of direct use of Neutron Client.

Change-Id: I77802ff65f975f8136daddfe897ae1993bd9c5e9
2020-03-31 08:15:38 +00:00
Brian Haley
0db5ab4e9e Remove backwards-compatibility check
The unit test setup has a try/except to support octavia-lib
< 1.3.1, but since that is the version in lower-constraints
it can never be triggered.  Remove it.

Change-Id: Ia28ecf4ffd1a0aaf7c7b28af9d6ec75b313d8abf
2020-03-23 17:16:42 -04:00
Brian Haley
2e4b7e5aa9 Add unit tests for hacking/checks.py
This also increases the coverage numbers a couple percent.

Change-Id: I8259868295a113093c1e7c1f7d11bd6759ca081c
2020-03-20 14:57:57 -04:00
Maciej JJózefczyk
af2b26afe6 Do not try to refresh vips on OVN LB that will be deleted
When there are multiple listeners with different protocols
configured on OVN LB, and one of listeners needs to be deleted,
there is no need to refresh vips on given OVN LB.
If there are no listners withing same protocol left the given OVN
LB could be deleted and there is no need to refresh vips then.

Change-Id: If15f817617facade10005878c8dfc7f467ce75a9
Closes-Bug: 1866087
2020-03-05 15:43:45 +01:00
Maciej Józefczyk
a6122e33da Wrap IPv6 address with brackets
If IPv6 address is not wrapped with brackets OpenFlow rules are
not properly installed.

Change-Id: Ib5836b004fd47671c4cdaa382c9376380beee448
Closes-Bug: #1863892
2020-02-28 20:52:30 +00:00
Maciej Józefczyk
17b1d9d573 Centralize traffic when LB and member has FIP
When Load Balancer and its member has FIP assigned
and environment is configured to use DVR the member
FIP needs to be centralized. It is current core OVN
limitation, that should be solved in [1].

This patch adds this mechanism to OVN Client and
OVN Octavia provider driver.

It covers cases:

1) FIP association on port that is a member of
   some LB - make it centralized.
2) FIP association on LB VIP - find a members
   FIPs and centralized them.
3) Add a member to LB that has FIP already
   configured - checks if a member has FIP
   and centralize it.
4) The reverse of each of the above cases.

In addition I needed to extend OVN LB member external_id
entry to add an information about member subnet_id
in order to easly track member port from mechanism OVN
driver.
That means I needed also to support both old and new
conventions. This patch adds also this code.

Old convention:
member_`member_id`_`ip_address`:`port`

New convention:
member_`member_id`_`ip_address`:`port`_`subnet_id`

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1793897

Related-Bug: #1860662

Change-Id: I254f0ac28f7585b699a8238e01ffb37dd70282ef
(cherry picked from networking-ovn commit 57ac38921efa6bbf0bc4a22950355256cc3ebe6d)
2020-02-28 11:59:02 -05:00
Maciej Józefczyk
42106d4696 Don't fail if VIP already exist or has been deleted before
Sometimes there is a race condition on creation of VIP port
or deleting it that ends with exception and blocks LB stack
creation / deletion.

Because for now we don't have running master branch
for OVN provider driver this change will be applied
first on stable/train in networking-ovn tree and then cherry-picked.

Change-Id: I2aaae7c407caba7a57e2ca2d4ed524f3bb63953f
Closes-Bug: #1860141
2020-02-25 08:25:39 +00:00
Maciej Józefczyk
439fc8f4b0 Don't send malformed status update to Octavia
In some corner cases while updating a member, OVN
Provider Driver sends a malformed status update
to Octavia that breaks the update operation and
resources stuck in PENDING_UPDATE state.

In OVN while resource is administratively disabled
we suffix its ID with string ':D'.
This patch filters this string from resources ID
before sending Octavia a status update.

Because for now we don't have running master branch
for OVN provider driver this change will be applied
first on stable/train and then cherry-picked.

Change-Id: Ib2ce04625faddd6ed263678bad2f4eb10929a520
Closes-Bug: #1860140
2020-02-24 14:16:41 +00:00
Maciej Józefczyk
45eee62660 Don't fail in case subnet or Logical Switch not found
In case of subnet not found all the related actions could
not be taken. This patch prevent this situation to happen.
This could be possible that LB is going to be deleted after
the subnet (for example remove of the LoadBalancer in Error
state).

The same could happend with Logical Switch. Sometimes the
member network is delated in meantime and then we tries to
the members. It means we would need to remove LB to LS and
LB to LR associations, but it could not happend because of
missing LS. In those terms now we just pass the flow
and remove the LS to LR counters in external_ids.

Change-Id: I44f6de4c9a2b1c6054417dbb7f647a6af8339660
Closes-Bug: 1857009
(cherry picked from networking-ovn 9aa7edd7852df98fe257d6a3b5c3b524398a1d4b)
2020-02-24 14:16:29 +00:00
Maciej Józefczyk
15260b7439 Add support for multiple L4 protocols withing same LB
This change introduces a way of providing multiple listeners and pools
on the same Load Balancer, but with different L4 protocols.

In case there are more than one unique protocol defined in Octavia pools
or Octavia listeners the OVN driver now adds another Load_Balancer row
per protocol, but with the same name. The selection of which OVN
Load_Balancer should be used is done by a protocol key.

This change also adds possibility to expose two listeners on the same
port, but with different L4 protocol. The common use-case is providing
a DNS service that listens both on UDP and TCP sockets.

Partial-Bug: #1789157
Change-Id: I2ee13b75713e7538d1b4f70207a90a95315eb914
2020-02-24 14:16:25 +00:00
Maciej Józefczyk
000049c15d Move OVN Octavia Provider driver code to this repository
This code moves OVN Octavia provider driver from networking-ovn
(branch master) repository to this repository.

For first step lets move code and unit tests.

Previous paths in networking-ovn tree:
./networking_ovn/octavia/ovn_driver.py -> ./ovn_octavia_provider/driver.py
./networking_ovn/tests/unit/octavia/test_ovn_driver ->
   ./ovn_octavia_provider/tests/unit/test_driver.py

There are a few files taken directly from neutron
repository that could be removed when neutron-lib
including those will be released:
./ovn_octavia_provider/ovsdb/impl_idl_ovn.py
./ovn_octavia_provider/ovsdb/ovsdb_monitor.py

Co-Authored-By: Brian Haley <bhaley@redhat.com>
Co-Authored-By: Carlos Goncalves <cgoncalves@redhat.com>
Co-Authored-By: Frode Nordahl <frode.nordahl@canonical.com>
Co-Authored-By: Jakub Libosvar <libosvar@redhat.com>
Co-Authored-By: Maciej Józefczyk <mjozefcz@redhat.com>
Co-Authored-By: Numan Siddique <nusiddiq@redhat.com>
Co-Authored-By: Reedip Banerjee <rbanerje@redhat.com>
Co-Authored-By: Terry Wilson <twilson@redhat.com>
Co-Authored-By: Yunxiang Tao <taoyunxiang@cmss.chinamobile.com>
Co-Authored-By: zhufl <zhu.fanglei@zte.com.cn>

Change-Id: I9b562c4ed5f74df2c3d600356758f4648ac7770b
Related-Blueprint: neutron-ovn-merge
2020-02-18 16:23:54 +00:00
Maciej Józefczyk
184f629f17 Initialize repository
This commit adds basic project configuration.

Change-Id: Ia5e4aa81213f34654e21e65ab44f4eea03851a9a
2020-01-15 14:41:32 +00:00