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
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
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
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
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
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
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
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
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
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.
Trivialfix
Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
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
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
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
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
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
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
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
Interface should be correctly removed from ironic when port-delete.
Nova should receive notify when baremetal port deleted.
Change-Id: I3d53bff8278dabafd929ecbea0b4b3b441c9e1cf
Partial-Bug: #1606229
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
- 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
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.
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.
Change-Id: Id7a941c1a461264ba44893d97cc6226f092e9888
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.
Change-Id: Iebb270be46b116df3441370dc1a6784571311aa9
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
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
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
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
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