Commit Graph

18 Commits

Author SHA1 Message Date
Boden R 4bd2f0e8f7 shim neutron rpc with neutron-lib
The common rpc and exceptions were rehomed into
neutron-lib with [1]. This patch shims those rehomed
modules in neutron to switch over to neutron-lib's
versions under the covers.

To do so:
- The rpc and common exceptions are changed to
reference their counterpart in neutron-lib effectively
swapping the impl over to neutron-lib.
- The fake_notifier is removed from neutron and lib's
version is used instead.
- The rpc tests are removed; they live in lib now.
- A few unit test related changes are required
including changing mock.patch to mock.patch.object,
changing the mock checks for a few UTs as they don't
quite work the same with the shim in place.
- Using the RPC fixture from neutron-lib rather than
that setup in neutron's base test class.

With this shim in place, consumers are effectively using
neutron-lib's RPC plumbing and thus we can move consumers
over to neutron-lib's version at will. Once all
consumers are moved over we can come back and remove
the RPC logic from neutron and follow-up with a consumption
patch.

NeutronLibImpact

[1] https://review.openstack.org/#/c/319328/

Change-Id: I87685be8764a152ac24366f13e190de9d4f6f8d8
2018-08-22 11:20:53 -06:00
Steve Kowalik 5ae71c833a Switch to oslo_messaging.ConfFixture.transport_url
oslo_messaging's rpc_backend setting, which is set by
ConfFixture.transport_driver has been deprecated since Newton. To allow
oslo_messaging to remove it, switch to setting transport_url instead.

Partial-Bug: #1712399
Change-Id: I2fbf5159febe9d4970935d77bd75e84204710c8e
2018-06-05 12:33:55 +10:00
Boden R 817f36e67a remove unused common rpc apis
Today neutron.common.rpc has a handful of public constants and functions
that are not used outside of neutron. This patch removes those not
externally used and enhances the rpc.init function to accept extra
RPC exception modules (though it's not used today) to still support
the notion of "extra mods" for RPC.

This patch also paves the way for easier rehoming the module to
neutron-lib.

Change-Id: I51607216a39980c17807dcccace3ab66b549607b
2018-03-09 12:13:48 -07:00
Ihar Hrachyshka 85d8f6f1c8 Catch exceptions for all rpc casts
I15cc2d6ae48e505c2da121880e27481dedf36d3b catches exceptions for
specific RPC endpoints affected by a recent change related to
push-notifications. There may be more changes like that in the future,
so instead of fixing them one by one, this patch consistently catches
exceptions from all cast calls for all RPC clients.

Change-Id: Ia7e6cd717758a9d5b18fe9cb07c55938f52040ce
Partial-Bug: #1705351
2017-07-27 09:03:00 -07:00
Ihar Hrachyshka c473876432 Switch to olso.messaging:get_rpc_transport
The old endpoint generates a deprecation warning:

neutron/common/rpc.py:61: DeprecationWarning: Using function/method
'oslo_messaging.transport.get_transport()' is deprecated: use
get_rpc_transport or get_notification_transport

TrivialFix

Change-Id: I51a3878dd0a50be2e4c4c93e6e7db4d330a22f23
2017-06-05 12:09:16 -07:00
Jenkins 2e7301f7a9 Merge "Switched rpc access policy to DefaultRPCAccessPolicy" 2017-04-17 23:36:27 +00:00
Ihar Hrachyshka aac17c6be9 Reconcile quitting_rpc_timeout with backoff RPC client
With backoff client, setting .timeout property on it doesn't take any
effect. It means that starting from Mitaka, we broke
quitting_rpc_timeout option.

Now, when the TERM signal is received, we reset the dict capturing
per-method timeouts; and we cap waiting times by the value of the
option. This significantly reduces time needed for the agent to
gracefully shut down.

Change-Id: I2d86ed7a6f337395bfcfdb0698ec685cf384f172
Related-Bug: #1663458
2017-03-21 01:26:31 +00:00
Ihar Hrachyshka 81f2d6c3ff Switched rpc access policy to DefaultRPCAccessPolicy
This should get rid of the following deprecation message:

FutureWarning: The access_policy argument is changing its default value
to <class 'oslo_messaging.rpc.dispatcher.DefaultRPCAccessPolicy'> in
version '?', please update the code to explicitly set None as the value:
access_policy defaults to LegacyRPCAccessPolicy which exposes private
methods. Explicitly set access_policy to DefaultRPCAccessPolicy or
ExplicitRPCAccessPolicy.

BTW the previous attempt [1] to get rid of the message was ineffective.
That's because the library does not distinguish between access_policy
explicitly picked by method consumer, and access_policy using the
default keyword value.

NeuttronLibImpact this change will break plugins that may expose RPC
                  endpoints that are prefixed with an underscore.

[1] Ia8922baf422ee84e55f05534678b2f0377843688

Change-Id: Ia2498eb5079050bfb4741c8b6c259bf1c116b8d6
2017-03-06 20:25:16 +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
ChangBo Guo(gcb) c7dd0ab6b8 Set access_policy for messaging's dispatcher
oslo.messaging allow dispatcher to restrict endpoint methods since
5.11.0 in I42239e6c8a8be158ddf5c3b1773463b7dc93e881, set with
LegacyRPCAccessPolicy explicitly to ensure it's compatible and
fix FutureWarning like:

"The access_policy argument is changing its default value to <class
'oslo_messaging.rpc.dispatcher.DefaultRPCAccessPolicy'> in version '?',
please update the code to explicitly set None as the value:
access_policy defaults to LegacyRPCAccessPolicy which exposes private
methods. Explicitly set access_policy to DefaultRPCAccessPolicy or
ExplicitRPCAccessPolicy.

Change-Id: Ia8922baf422ee84e55f05534678b2f0377843688
2017-01-24 13:56:49 +08:00
Ihar Hrachyshka 8ad62fe751 Remove old oslo.messaging transport aliases
Those are remnants from the oslo-incubator times. Also, oslo.messaging
deprecated [1] transport aliases since 5.2.0+ that is the minimal
version supported for stable/newton. The patch that bumped the minimal
version for Neutron landed 3 months+ ago, so we can proceed ripping
those aliases from the code base.

[1] I314cefa5fb1803fa7e21e3e34300e5ced31bba89

Change-Id: I9e66140ad0b10c50e216c78e4914c98313cada05
Closes-Bug: #1424728
2016-09-30 14:13:19 +00:00
Jenkins 7e450dc9f4 Merge "Use from_dict to load context params" 2016-08-26 22:00:11 +00:00
Anindita Das 414ceed4f3 Refactoring config options for common config opts
Refactoring neutron common config opts to be in neutron/conf/common so
that all the configuration options reside in a centralized location.
This simplifies the process of looking up the config opts and provides
an easy way to import.

Moved conf/common/config.py to conf/common.py as per review comments.

Partial-Bug: #1563069

Change-Id: Ib5fa294906549237630f87b9c848eebe0644088c
2016-07-26 15:55:49 +00:00
Jamie Lennox 8ad224d4e6 Use from_dict to load context params
The context objects accepts and ignores unknown keyword arguments. This
was to allow it to handle the deserialization of parameters it didn't
understand from the base class' to_dict method. This will make it
difficult to pass unknown attributes to the base class so fix the
from_dict method to only accept params it knows about.

Related-Bug: #1602081
Change-Id: Ic58a2025680e8e1ba4f8a177d898be457e2c3160
2016-07-12 13:49:41 +10:00
Kevin Benton 3e668b6a37 Add exponential back-off RPC client
This adds an exponential backoff mechanism for timeout values
on any RPC calls in Neutron that don't explicitly request a timeout
value. This will prevent the clients from DDoSing the server by
giving up on requests and retrying them before they are fulfilled.

Each RPC call method in each namespace gets its own timeout value since
some calls are expected to be much more expensive than others and we
don't want to modify the timeouts of cheap calls.

The backoff currently has no reduction mechanism under the assumption
that timeouts not legitimately caused by heavy system load
(i.e. messages completely dropped by AMQP) are rare enough that the
cost of shrinking the timeout back down and potentially causing
another server timeout isn't worth it. The timeout does have a ceiling
of 10 times the configured default timeout value.

Whenever a timeout exception occurs, the client will also sleep for a
random value between 0 and the configured default timeout value to
introduce a splay across all of the agents that may be trying to
communicate with the server.

This patch is intended to be uninvasive for candidacy to be
back-ported. A larger refactor of delivering data to the agents
is being discussed in I3af200ad84483e6e1fe619d516ff20bc87041f7c.

Closes-Bug: #1554332
Change-Id: I923e415c1b8e9a431be89221c78c14f39c42c80f
2016-05-05 09:50:54 +00:00
Ryan Rossiter d3ee7a5338 Add separate transport for notifications
In oslo.messaging 2.9.0, the RPC and notification buses were decoupled
into separate transport. This changes over the Neutron notifier to use
the notification transport provided from oslo.messaging instead of the
original transport (which is now used for RPC). By default, the
notification transport will pull in the original transport if nothing is
configured in oslo_messaging_notification, so this can be an in-place
replacement without impacting upgrades or configurations.

This functionality was added to oslo.messaging to address bug #1504622

Change-Id: I89c8a84c81079677088cc7d656a0bcb5e323de4d
2016-01-26 17:40:03 +00:00
Ryan Rossiter e4f2fb9df6 Add tests for RPC methods/classes
The public methods and classes within the neutron.common.rpc module are
untested. This adds tests for all public-facing functions within the
module.

Closes-Bug: #1535327
Change-Id: I80227dd73e58f8b5dbde9cea01ceac22cc8b2e34
2016-01-18 15:10:44 +00: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