Commit Graph

36 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez cc38cb0cee [sqlalchemy-20] Use the correct OVO field type
In "test_notify_port_status_all_values", to create the Port OVO it
is needed to pass the correct field values. "status" only accepts
strings.

Closes-Bug: #2027610
Change-Id: Icccaa9176ecd53b69cd8d80f24267f87bbb6ed13
2023-07-12 18:00:57 +00:00
Szymon Wroblewski 9081ce369e Fix test_nova_send_events_* tests
mock().foo.bar and mock.foo.bar generate different mocks.
Fix mocks to reflect actual use of nova client and
add assert to verify create function was actually called.

Change-Id: I0bec5ceb0dac5d233ca371865e99f93cbe417b68
2022-09-06 11:40:10 +02:00
Szymon Wroblewski cd475f9af8 Retry connections to Nova
Sometimes Neutron is failing to send notification to Nova
due to timeout, refused connection or another HTTP error.
Retry send in those cases.

Closes-Bug: #1987780
Change-Id: Iaaccec770484234b704f70f3c144efac4d8ffba0
2022-09-02 11:26:40 +02:00
Rodolfo Alonso Hernandez 507989fc62 Use a thread local variable to store the Nova Notifier enable flag
The Nova Notifier can be called simultaneously by several RPC
callbacks from the agents (DHCP, L2), trying to update the provisioning
status of a port. In order to handle each context notifier enable flag,
a thread local variable is used. This will isolate the flag update
if two entities inform at the same time and one RPC callback is attended
during the processing of the other one.

This patch also removes the debug messages added to debug this issue.

Closes-Bug: #1958363
Change-Id: Ie670fba4b3afe427747732d2c3948d92311e960e
2022-02-02 08:03:38 +00:00
shanyunfan33 0e6257606a remove unicode from code
remove unicode from code

Change-Id: Ide37b3c1f8a2e2dcdcac0a2b0631cb197eca5baf
2021-12-24 10:02:03 +08:00
Slawek Kaplonski e94511cd25 Add config option ``http_retries``
This option allows to configure Number of times nova or ironic client
should retry on any failed http call.
Default value for this new option is "3".

Change-Id: I795ee7ca729646be0411a1232bf218015c65010f
Closes-Bug: #1883712
2020-06-29 22:07:46 -04:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are 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". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Rodolfo Alonso Hernandez 8b7d2c8a93 Refactor the L3 agent batch notifier
This patch is the first one of a series of patches improving how the L3
agents update the router HA state to the Neutron server.

This patch partially reverts the previous patch [1]. When the batch
notifier sends events, it calls the callback method passed during the
initialization, in this case AgentMixin.notify_server. The batch
notifier spawns a new thread in charge of sending the notifications and
then wait the specified "batch_interval" time. If the callback method is
not synchronous with the notify thread execution (what [1] implemented),
the thread can finish while the RPC client is still sending the
HA router states. If another HA state update is received, then both
updates can be executed at the same time. It is possible then that a new
router state can be overwritten with an old one still not sent or
processed.

The batch notifier is refactored, to improve what initally was
implemented [2] and then updated [3]. Currently, each new event thread
can update the "pending_events" list. Then, a new thread is spawned to
process this event list. This thread decouples the current execution
from the calling thread, making the event processing a non-blocking
process.

But with the current implementation, each new process will spawn a new
thread, synchronized with the previous and new ones (using a
synchronized decorator). That means, during the batch interval time, the
system can have as many threads waiting as new events received. Those
threads will end secuentially when the previous threads end the batch
interval sleep time.

Instead of this, this patch receives and enqueue each new event and
allows only one thread to be alive while processing the event list. If
at the end of the processing loop new events are stored, the thread will
process then.

[1] I3f555a0c78fbc02d8214f12b62c37d140bc71da1
[2] I2f8cf261f48bdb632ac0bd643a337290b5297fce
[3] I82f403441564955345f47877151e0c457712dd2f

Partial-Bug: #1837635

Change-Id: I20cfa1cf5281198079f5e0dbf195755abc919581
2019-08-01 17:11:04 +00:00
Brian Haley b79842f289 Start enforcing E125 flake8 directive
Removed E125 (continuation line does not distinguish itself
from next logical line) from the ignore list and fixed all
the indentation issues.  Didn't think it was going to be
close to 100 files when I started.

Change-Id: I0a6f5efec4b7d8d3632dd9dbb43e0ab58af9dff3
2019-07-19 23:39:41 -04:00
Takashi NATSUME 86b3993cee Fix misuse of assertTrue/assertFalse
Change-Id: I247705feeb71e20ad5260b0ca1da08de7290ba6e
Closes-Bug: #1819982
2019-03-14 09:16:10 +09:00
openstack 75d83b9032 Send global_request_id for tracing calls from neutron to nova
Neutron makes call to nova for sending notifications but here no
context object user/admin available, so generated a request_id
and passed it as global_request_id during novaclient initialization
so that nova will log both global_request_id and it's own generated
request_id in the context formatter for traceability. As Notifier
class is used as singleton mode, need to create novaclient every time
events are sent from neutron to nova.

Modified unit tests wherever applicable.

Oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42

Change-Id: I94257bd6ec9ec6b9a1f509c27c439e6305e43e63
2018-11-30 05:41:24 +00:00
Brian Haley 90cd939047 Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.

Trivialfix

Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
2018-04-17 14:22:58 +00:00
Manjeet Singh Bhatia 1e239de5dc Use port object in notifiers/test_nova.py
As port object is ready to use. this patch replaces
the direct use of port model with port object in
tests/unit/notifiers/test_nova.py

This patch removes also test "test_port_without_id_no_notify"
as Port object can't be created without ID field configured
or generated automatically by DB.

Co-Authored-By: Slawek Kaplonski <slawek@kaplonski.pl>
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Change-Id: If8d291e36a6c94441335afa98d146e3fc9975209
2017-10-03 20:59:01 +00:00
Boden R 0a1405794f use service type constants from neutron_lib plugins
The well known service type constants are in
neutron_lib.plugins.constants, but for legacy reasons a few still exist
and are referenced from neutron_lib.constants that we'd like to remove.
This patch switches references over to neutron_lib's plugin constants.

Change-Id: I1861448cec303725b30cef8f42029f467f9e03a3
2017-06-27 15:16:05 -06:00
Matt Riedemann bf8e6007cf Send port ID in network-changed event to Nova
When Nova gets a network-changed event, it rebuilds the
entire network info cache for the instance if it does not
have a specific port ID. This can be costly and redundant
when performing something like a live migration with multiple
ports attached to the same instance.

This change simply adds the port ID to the network-changed event
since we have it in scope. Nova can use it or not, but at least
the information is provided for context.

Change-Id: Ifdaef05208d09ddd9587fed6214cf388e5265ba4
Closes-Bug: #1691602
2017-05-17 22:18:54 -04:00
Jenkins 01baa8c541 Merge "Remove baremetal notification from nova notifier" 2017-03-15 02:46:20 +00:00
Ken'ichi Ohmichi 551ba9580b Bump to Nova V2.1
Nova V2.1 API has been available since Kilo, and the API is CURRENT.
Neutron is using Nova API via novaclient and the used Nova API is
V2.1 on the gate as the default Nova endpoint. So this patch doesn't
change the used Nova API actually, but current novaclient skips checking
expected API version in a response from Nova API.
This patch will be helpful to avoid an issue when enabling this check
on novaclient side.

NOTE: Cinder is using Nova v2.1 API with the similar patch as
      Iadd3363265be6c5a8ed46704a712da6c15e2b046

Change-Id: Ie3a10f7078f4213da77be522e3866f82b5e8683c
2017-03-03 14:08:01 -08:00
Sam Betts cb6eae20fa Remove baremetal notification from nova notifier
This is a revert of change I3d53bff8278dabafd929ecbea0b4b3b441c9e1cf

The nova notifier was updated to notify nova on ports with the
baremetal: device_owner, these ports are owned by Ironic not Nova, so
nova is getting notifications that it doesn't understand.

Change-Id: I8318a682163f6a5b739be68ce56973c43d0e32f2
Closes-Bug: #1656010
Depends-On: I43c3af9f424a65211ef5a39f13e4810072997339
2017-01-27 11:54:28 +00:00
Armando Migliaccio 17563a802e Adopt neutron-lib plugin directory
Neutron Manager is loaded at the very startup of the neutron
server process and with it plugins are loaded and stored for
lookup purposes as their references are widely used across the
entire neutron codebase.

Rather than holding these references directly in NeutronManager
this patch refactors the code so that these references are held
by a plugin directory.

This allows subprojects and other parts of the Neutron codebase
to use the directory in lieu of the manager. The result is a
leaner, cleaner, and more decoupled code.

Usage pattern [1,2] can be translated to [3,4] respectively.

[1] manager.NeutronManager.get_service_plugins()[FOO]
[2] manager.NeutronManager.get_plugin()
[3] directory.get_plugin(FOO)
[4] directory.get_plugin()

The more entangled part is in the neutron unit tests, where the
use of the manager can be simplified as mocking is typically
replaced by a call to the directory add_plugin() method. This is
safe as each test case gets its own copy of the plugin directory.
That said, unit tests that look more like API tests and that rely on
the entire plugin machinery, need some tweaking to avoid stumbling
into plugin loading failures.

Due to the massive use of the manager, deprecation warnings are
considered impractical as they cause logs to bloat out of proportion.

Follow-up patches that show how to adopt the directory in neutron
subprojects are tagged with topic:plugin-directory.

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Gary Kotton 9f09f27c5d Fix deprecation warnings
Remove deprecation warnings for various constants
and exceptions that have moved to neutron_lib.

Fix miscellaneous other deprecations.

Uses constants instead of l3_constants when importing
neutron-lib constants.

Co-Authored By: Henry Gessau <gessau@gmail.com>
Co-Authored By: Gary Kotton <gkotton@vmware.com>

Change-Id: Ib0e8ff5c3e23677c1009241a1818cbc8a3430c38
2016-08-26 22:16:06 -04:00
Andrey Shestakov 8b69189fdd Consider baremetal device_owner as compute for nova notify
Interface should be correctly removed from ironic when port-delete.
Nova should receive notify when baremetal port deleted.

Change-Id: I3d53bff8278dabafd929ecbea0b4b3b441c9e1cf
Partial-Bug: #1606229
2016-08-05 08:34:22 +00:00
Jenkins 3fb38b41f7 Merge "Notify nova with network-vif-plugged in case of live migration" 2016-07-25 21:54:55 +00:00
rossella 6e275e3857 When deleting floating IP catch PortNotFound
If we try to delete a VM and to delete the floating IP
associated with the VM at the same time, depending
on the order according to which these requests are processed
Neutron might fail in the deletion of the floating IP,
raising a PortNotFound error. This happens because Neutron
notifies Nova of the network change event and it tries to get
the port to which the FIP is associated. If the port is not there,
Neutron shouldn't raise, it shouldn't send any notification.

Change-Id: Ic72313ad1f787b3cb528e806c843f1fd01eb12f2
Closes-bug: #1586931
2016-07-06 11:14:07 +00:00
Oleg Bondarev b7c303ee0a Notify nova with network-vif-plugged in case of live migration
- during live migration on pre migration step nova plugs instance
   vif device on the destination compute node;
 - L2 agent on destination host detects new device and requests device
   info from server;
 - server does not change port status since port is bound to another
   host (source host);
 - L2 agent processes device and sends update_device_up to server;
 - again server does not update status as port is bound to another host;

Nova notifications are sent only in case port status change so in this case
no notifications are sent.

The fix is to explicitly notify nova if agent reports device up from a host
other than port's current host.

This is the fix on neutron side, the actual fix of the bug is on nova side:
change-id Ib1cb9c2f6eb2f5ce6280c685ae44a691665b4e98

Closes-Bug: #1414559
Change-Id: Ifa919a9076a3cc2696688af3feadf8d7fa9e6fc2
2016-07-06 10:47:27 +00:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
Bhagyashri Shewale 88e899f7a0 Fix module's import order
Made corrections in import order for built-in, third party and
project specific modules as per OpenStack import standards [1].

[1] http://docs.openstack.org/developer/hacking/#import-order-template

Change-Id: I899deefd6ee4732d6c0afd17a5afbe42b0fa37ba
2016-01-22 06:38:42 -08:00
Jeremy McDermond 7dad96deb4 Add option for nova endpoint type
When the neutron notification to nova was updated to use novaclient the
nova_url parameter was disabled.  This prevents administrators from
using anything but the publicURL as the proper endpoint to notify nova.
This patch adds an option to pass on to novaclient for the
endpoint_type so that the administrator can set the notification url to
public, internal or admin.

Change-Id: I405f761944449cab6b8c8895f98419f79cd74cad
Closes-Bug: #1478471
DocImpact: Need to add a new option to the neutron configuration
reference.
2015-12-10 08:40:36 +00:00
Gary Kotton 50be190b68 Use DEVICE_OWNER_* for 'network:*' constants
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.

Change-Id: Id7a941c1a461264ba44893d97cc6226f092e9888
2015-11-16 20:45:36 -08:00
Ihar Hrachyshka fb2a5bd4cf Use DEVICE_OWNER_COMPUTE constant everywhere
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.

Change-Id: Iebb270be46b116df3441370dc1a6784571311aa9
2015-11-14 18:54:17 +01:00
Cedric Brandily fd7f84b20b Use assertIsNone(observed) instead of assertEqual(None, observed)
Neutron should use the specific assertion:

  self.assertIsNone(observed)

instead of the generic assertion:

  self.assertEqual(None, observed)

as it raises more specific errors.

Closes-Bug: #1503055
Change-Id: Ib7e5875bd0a95320d89a7504f951998fb210acc1
2015-10-06 01:06:11 +02:00
Jenkins a39c73ec6f Merge "Revert "Revert "Add VIF_DELETED notification event to Nova""" 2015-08-12 18:05:47 +00:00
ChangBo Guo(gcb) c3d65a0ed9 Switch to oslo_utils.uuidutils
Get rid of oslo-incubator uuidutils

Closes-Bug: #1467020
Depends-On: I2df519965883b05d5d58cdc4785c850b0685dc2c
Depends-On: I9f8e98ad9517864a9ffdacf01c0a9a5aab554edb
Depends-On: Ied0faac809a5b72b1cd466c8babc9ca5418692c3
Change-Id: Iebe491b981b4b7c02785412fadd27678bb5e47de
2015-06-22 11:06:18 +00:00
Kevin Benton d477dbcf58 Revert "Revert "Add VIF_DELETED notification event to Nova""
This reverts commit 6575db592c.

Depends-on: I998b6bb80cc0a81d665b61b8c4a424d7219c666f

DocImpact
If Neutron is upgraded to Liberty before the Nova API is,
the Nova API log will contain errors complaining that it doesn't
understand this new event. Nothing will be broken, but there will
be an error every time a port is deleted until Nova is upgraded.

Change-Id: I7aae44e62d2b1170bae31c3492148bfd516fb78b
2015-06-14 02:20:27 +00:00
Kevin Benton 6575db592c Revert "Add VIF_DELETED notification event to Nova"
We need to wait until the nova support is added in
I998b6bb80cc0a81d665b61b8c4a424d7219c666f. Otherwise
this generates a ton of error messages in the nova api
log as well as on the neutron side.

This reverts commit 0ace88fd4a.

Change-Id: I129c4e4c05cf07d45032fec6f57e0cc17a5a82af
Closes-Bug: #1461391
2015-06-03 05:52:51 +00:00
Robert Li 0ace88fd4a Add VIF_DELETED notification event to Nova
It's possible to delete a neutron port that is currently associated
with an instance. When it happens, neutron should notify nova of the
port deletion event so that Nova can take proper actions.

Refer to I998b6bb80cc0a81d665b61b8c4a424d7219c666f for the nova patch
that handles the event.

Change-Id: Iff88cd12ae18017ef3e776821bcf3ecf3b4f052f
Related-Bug: #1333365
Related-Bug: #1448148
2015-05-12 11:17:32 -04:00
Maru Newby 1105782e39 Reorganize unit test tree
This change ensures that the structure of the unit test tree matches
that of the code tree to make it obvious where to find tests for a
given module.  A check is added to the pep8 job to protect against
regressions.

The plugin test paths are relocated to neutron/tests/unit/plugins
but are otherwise ignored for now.

Change-Id: If307593259139171be21a71c58e3a34bf148cc7f
Partial-Bug: #1440834
2015-04-06 23:28:31 +00:00