Commit Graph

71 Commits

Author SHA1 Message Date
Tobias Urdin 687dea2e65 Support overriding class for get_rpc_* helper functions
We currently do not support overriding the class being
instantiated in the RPC helper functions, this adds that
support so that projects that define their own classes
that inherit from oslo.messaging can use the helpers.

For example neutron utilizes code from neutron-lib that
has it's own RPCClient implementation that inherits from
oslo.messaging, in order for them to use for example
the get_rpc_client helper they need support to override
the class being returned. The alternative would be to
modify the internal _manual_load variable which seems
counter-productive to extending the API provided to
consumers.

Change-Id: Ie22f2ee47a4ca3f28a71272ee1ffdb88aaeb7758
2023-01-23 08:40:37 +00:00
Tobias Urdin 4ead7cb2dc Implement get_rpc_client function
We already expose functions to handle the instantiation
of classes such as RPCServer and RPCTransport but the
same was never done for RPCClient so the API is
inconsistent in its enforcement.

This adds a get_rpc_client function that should be used
instead of instatiating the RPCClient class directly to
be more consistent.

This also allows to handle more logic inside the function
in the future such as if implementations for an async client
is implemented, as investigation in [1] has shown.

[1] https://review.opendev.org/c/openstack/oslo.messaging/+/858936

Change-Id: Ia4d1f0497b9e2728bde02f4ff05fdc175ddffe66
2022-10-25 11:42:40 +00:00
Ching Kuo bdbb6d62ee Add Support For oslo.metrics
This commit added support to send rpc metrics to oslo.metrics.

Changes includes:
- Adding client wrapper for oslo.metrics to process metrics information
  and send to oslo.metrics socket
- Modify rpc client to send metric when certain rpc events happens

For more information on oslo.metrics
https://opendev.org/openstack/oslo.metrics

Change-Id: Idf8cc0e52ced1f697ac4048655eff4c956fd5c79
2021-06-08 22:22:37 +08:00
xuanyandong 642367cdfd remove unicode from code
Change-Id: Ib2b816728307166450a4cea2ccdb3c4b550a0713
2021-01-03 16:11:46 +08:00
Arnaud Morin 82492442f3 Add a ping endpoint to RPC dispatcher
The purpose of this patch is to add an endpoint directly in RPC
dispatcher, so this endpoint will always be available, in a cross
project manner, without the need for projects to manage it by themself.

This endpoint stay disabled by default, so this change is harmless
without a specific configuration option.

To enable this ping endpoint, an operator will just have to add a new
parameter in the [DEFAULT] section, alongside with rpc_response_timeout
[DEFAULT]
rpc_ping_enabled=true  # default is false

The purpose of this new endpoint is to help operators do a RPC call (a
ping) toward a specific RPC callback (e.g. a nova-compute, or a
neutron-agent).
This is helping a lot for monitoring agents (for example, if agents are
deployed in a kubernetes pod).

The endpoint is named oslo_rpc_server_ping.

Change-Id: I51cf67e060f240e6eb82260e70a057fe599f9063
Signed-off-by: Arnaud Morin <arnaud.morin@corp.ovh.com>
2020-08-18 15:09:29 +02:00
Andreas Jaeger e44c988306 Remove six usage
Remove six, the python 2/3 compatibility library. It's not needed
anymore since the repo is python3 only.

Remove a now unneeded hacking test.

Change-Id: I40522c4accb4aaf8115d11fee8b081e2d991cb4d
2020-05-11 10:21:58 +02:00
Hervé Beraud fed48aea44 Remove the deprecated blocking executor
The blocking executor has been deprecated in Pike and marked for removal
in Rocky, but some user like Mistral asked us to wait before. We decided
to remove this executor for Train or next cycle, now we are in the
Ussuri and after some researchs on usage I think we can go ahead.

This patch drop the deprecation warnings, related unit tests and
set the server with the threading executor is the default executor.

Change-Id: If07bab61ee2b148658b88be98b12f8539f274efe
Closes-Bug: #1715141
2020-02-18 15:49:27 +01:00
Oleg Bondarev d7eb89eac8 Don't log NoSuchMethod for special non-existing methods
Such non-existing methods are used as health probes.
Please see bug for details.

Change-Id: I8f6b4a669ec11721f76cf03abcd7d802c3c11eb5
Closes-Bug: #1857319
2020-01-23 15:37:31 +04:00
John Eckersberg d873c0d8f5 Do not use threading.Event
Waiting on a threading.Event with eventlet can cause busy looping via
epoll_wait, see related bug for more details.

Change-Id: I007613058a2d21d1712c02fa6d1602b63705c1ab
Related-bug: #1518430
2019-12-18 13:11:41 +00:00
Kenneth Giusti 859e0d4eaa Revert "Add RPC incoming and reply log"
This broke non-rabbitmq message bus drivers. See:

https://bugs.launchpad.net/oslo.messaging/+bug/1855775

This reverts commit b104f254ab.

Change-Id: I17a448a768b544482b375b0076889db989e03e8c
2019-12-09 16:22:06 -05:00
LIU Yulong b104f254ab Add RPC incoming and reply log
Typically a simple log will not narrow down the
performance, but give us more information about
the service status.

Change-Id: I51c8f2743dd39cccd3d1d021d3c50dc09f70cd97
Closes-Bug: #1847747
2019-10-21 22:32:07 +08:00
Gabriele b7e9faf659
Add the mandatory flag for direct send
With this feature, the server will raise and log a Message Undeliverable
exception. So it is possible to log immediately an error in case the
reply queue does not exist for some reason.

This is part of blueprint transport-options
The blueprint link is [1]
Please follow the link [2] to use and test the feature.

1-
https://blueprints.launchpad.net/oslo.messaging/+spec/transport-options
2- https://github.com/Gsantomaggio/rabbitmq-utils/
tree/master/openstack/mandatory_test

Change-Id: Iac7474c06ef425a2afe5bcd912e51510ba1c8fb3
2019-08-21 14:46:59 +02:00
Gabriele 83266cc6ea
Add transport_options parameter
With this new parameter is possible to pass other parameters
from the client to the drivers.
So it is possible to tune the driver behavior.

For example can be used to send the mandatory flag in RabbitMQ

Note:
  - The transport_options parameter is not actually used (yet).
  - This part of blueprint transport-options  (first part)

Implements: blueprint transport-options
The blueprint link is
https://blueprints.launchpad.net/oslo.messaging/+spec/transport-options

Change-Id: Iff23a9344c2c87259cf36b0d14c0a9fc075a2a72
2019-06-14 15:47:39 +02:00
Hervé Beraud 4f385720d7 Remove log translation and i18n
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

Change-Id: I9ddb6595fc52e46ed8844e39d2fa71029c90b65c
Closes-Bug: #1674567
2019-04-24 11:55:38 +02:00
Zuul 78777a92b8 Merge "Handle unexpected failures during call monitor heartbeat" 2019-04-22 22:11:48 +00:00
Kenneth Giusti f948e24294 Handle unexpected failures during call monitor heartbeat
Change-Id: Iec04c18ac3565a3610377d94caf128c6704a89eb
Closes-Bug: #1816816
2019-02-20 15:07:31 -05:00
ZhijunWei cb902e5aff Update hacking version
update the hacking to latest, duo to[1]

[1]: https://github.com/openstack/oslo.messaging/blob/master/HACKING.rst

Change-Id: I1ee7387272690f0de0d7b1937d7c2b0ee404063c
2019-01-21 19:45:42 -05:00
Kenneth Giusti 26b0be585a Issue blocking ACK for RPC requests from the consumer thread
The patch for https://review.openstack.org/#/c/436958/ fixed a
threading problem by moving the ack back to the polling
thread. However the RPC server expects to catch any failures of the
ACK and abort the request.  This patch adds the ACK error handling
back to the polling thread.

This patch is based heavily off the original work done by Mehdi
Abaakouk (sileht).

Change-Id: I708c3d6676b974d8daac6817c15f596cdf35817b
Closes-Bug: #1695746
2018-07-11 08:59:35 -04:00
Dan Smith b34ab8b1cc [rabbitmq] Implement active call monitoring
This adds an optional call_monitor_timeout parameter to the RPC client,
which if specified, will enable heartbeating of long-running calls by
the server. This enables the user to increase the regular timeout to
a much larger value, allowing calls to take a very long time, but
with heartbeating to indicate that they are still running on the server
side. If the server stops heartbeating, then the call_monitor_timeout
takes over and we fail with the usual MessagingTimeout instead of waiting
for the longer overall timeout to expire.

Change-Id: I60334aaf019f177a984583528b71d00859d31f84
2018-05-09 10:08:37 -07:00
zhangxuanyuan 3a9c01ffe9 Fix default value of RPC dispatcher access_policy
Change-Id: I4d30ff269b2e34f4409e8d1ce822eb93918cf5a2
Closes-Bug: #1712393
2017-09-24 20:25:38 -07:00
Rajath Agasthya 03b6f18f80 Warn when wrong transport instance is used
Since RPC and notifications can have different backends, it is
useful to warn users if they use a notification transport in RPC
and vice versa. This patch introduces RPCTransport and
NotificationTransport subclasses of Transport, so it's easier to
add different behavior for them if need be.

Related-Bug: #1680192
Change-Id: Iab60544d69053c8e74c28a2d5c84665be749013f
2017-09-11 07:07:30 -07:00
Kenneth Giusti b7382d58d7 Ensure RPC endpoint target attribute is correct
An endpoint can have an optional 'target' attribute which is used to
filter the callable endpoint by the target.version or .namespace
attributes.  Therefore 'target' is reserved and attempting to use an
endpoint that overrides the target attribute (say with a function
call) should fail with a TypeError.

Change-Id: I0bbf9fca0ecbe71efa87c9613ffd32eb718f2c0e
Closes-Bug: #1709131
2017-08-16 12:00:46 -04:00
zhiCHang1990 1389893dd0 Add monkey_patch to demo code.
The RPC server code can not work if we
don't add eventlet.monkey_patch() at the
begining.

Change-Id: I65a162a427fb5615c95a70e6d1bbec899a78f231
2017-07-11 09:45:08 +08:00
Mehdi Abaakouk 2566be199a deprecated blocking executor
Using blocking executor is not recommended for application. But it looks
like some use it just because it's the default and are not aware their
should change it despite of documentation and logging message.

Choosing the application threading model is an important step
of an application.

This change deprecates it, in the future we will just make executor
mandatory. This will ensure that application make a choice.

Also this will reduce headache of oslo.messaging developers to
make the driver code working in a sync and async.

And to finish test coverage of blocking executor is 0%...

This rework some tests to remove logging.captureWarnings() that can
catch unwanted warning of other tests. Tests mocks warning instead.

Related-bug: #694728
Change-Id: Ic67164d12e7a9bed76d6e64ca2ced12e3984ff5f
2017-06-04 14:27:41 +02:00
Kenneth Giusti c7d880c33a Clean up the TransportURL documentation
Be specific regarding which characters can be used in the 'username'
and 'password' fields of the URL.

Change-Id: I9a2a801b3dd86fceffb05f4d52c715748c88d0cb
Closes-Bug: #1693967
2017-06-01 15:43:03 -04:00
Andrew Smith ec4d6639bc Add get_rpc_transport call
The get_rpc_transport wraps get_transport to unify the API in
anticipation of comprehensive separation of RPC and Notification
messaging backends.

Related-Bug: 1680192
Change-Id: Ic6af07b98ff43806c2af38a3ba129991f1e0ec86
2017-05-12 12:30:41 -04:00
ChangBo Guo(gcb) abc269b7e5 Trivial: Add executor 'threading' in docstring
oslo.messaging supports three types of executors: blocking, eventlet
and threading, so it's good to list all of them in docstring.

Change-Id: Ief14d54b5f029cf3e9c79334e405dca5cf2dc13d
2017-03-20 17:24:32 +08:00
ChangBo Guo(gcb) 8cbca30afd Move decorator updated_kwarg_default_value to right place
debtcollector's decorator updated_kwarg_default_value is used to indicate
default value will be changed in future version. We introduced parameter
access_policy and add itfor constructor method of RPCDispatcher in
d3a8f280eb. Other services usually call
get_rpc_server method instead of calling constructor method of
RPCDispatcher. get_rpc_server method constructs RPCDispatcher instance
in [1], then FutureWarning will be generated even we set parameter
access_policy explicitly. Need move the decorator updated_kwarg_default_value
to method get_rec_server to avoid the case.

Closes-Bug: #1661572

[1] f1efaf1b6e/oslo_messaging/rpc/server.py (L200).

Change-Id: I3214045856d0bbd05a0000eeafb769e4697cd34c
2017-03-07 03:39:30 +00:00
jolie f1efaf1b6e fix one typo
Change-Id: Ie4ce6e4a8bad8610b40050c94bb3d0796f9f4d2f
2016-12-21 17:52:14 +08:00
Li-zhigang ea8fad47a5 Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using six.iteritems to achieve iterators.
We can use dict.items instead, as it will return iterators in PY3 as well.
And dict.items/keys will more readable. 2.In py2, the performance about
list should be negligible, see the link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: Ia235afc3532f62f265f91ca46d2306c72fc2a2a2
2016-11-23 09:02:14 +00:00
ChangBo Guo(gcb) 0b075aa40a Remove useless logging import statements
TrivialFix

Change-Id: I0bcefbe144903b45d71e053162066d6d4bc91936
2016-11-08 10:11:13 +08:00
Jenkins 9a5ce19075 Merge "Removed redundant 'the'" 2016-10-10 16:44:09 +00:00
melissaml fa43769080 Removed redundant 'the'
Removed redundant 'the'

Change-Id: Iba66e79c38ebc79c2f916f0704b00927849061c3
2016-10-08 13:17:18 +08:00
melissaml ea001a874b Fix a typo in server.py
TrivialFix

Change-Id: I550661e58e481e69b2f21600893a20692aa9e9f3
2016-10-08 12:28:12 +08:00
Kenneth Giusti 9bc9c0dc6a Fixups to the inline documentation
Rework the inline documentation for executors, RPC servers and
clients, notifiers and notification listeners for clarity and flow.

Change-Id: If4f1db853a7fc85340177fd2c9c43a479d72459d
2016-09-12 09:49:00 -04:00
Paul Vinciguerra d3a8f280eb Allow dispatcher to restrict endpoint methods.
Implements access_policy for dispatcher to restrict endpoint methods.

Implements the following access policies:
* LegacyRPCAccessPolicy
* DefaultRPCAccessPolicy
* ExplicitRPCAccessPolicy

* Implement decorator @rpc.expose for use with the
 ExplicitRPCAccessPolicy

* Modify get_rpc_server to allow optional access_policy argument
* Set default access_policy to LegacyRPCAccessPolicy (Nova exposes
 _associate_floating_ip in tempest tests). Added debtcollector
 notification.
* Add test cases for access_policy=None
* Clarify documentation

Change-Id: I42239e6c8a8be158ddf5c3b1773463b7dc93e881
Closes-Bug: 1194279
Closes-Bug: 1555845
2016-08-30 20:32:35 -04:00
Gevorg Davoian 9ccfbdd3c3 Fix problems after refactoring RPC client
The patch fixes some problems arised after merging the previous
patch which this patch depends on.

Change-Id: If38edec19f9bffc8ac54818b2536243a9edaf7e8
Depends-On: I608c828123b196099933d16801f8ce7d9dd3a079
Closes-Bug: #1584889
2016-05-24 12:37:26 +03:00
Gevorg Davoian 39749c77a8 Remove logging from serialize_remote_exception
This patch removes log_failure argument from the function
serialize_remote_exception and from driver implementations
using it (because it is never used and always defaults to True)
and prevents error logging in this function (because these errors
are already logged by servers while processing incoming messages).

Change-Id: Ic01bb11d6c4f018a17f3219cdbd07ef4d30fa434
Closes-Bug: 1580352
2016-05-19 15:18:28 +03:00
Jenkins 46a98cf50e Merge "Fix bug with version_cap and target.version in RPCClient" 2016-05-18 11:26:35 +00:00
Gevorg Davoian 32a7c1c0a4 Fix bug with version_cap and target.version in RPCClient
This patch fixes the bug in the RPCClient class when a client's
version_cap is set, but target.version is unset. The code does not
check this case, which results in unhandled exceptions.

Change-Id: I623c14b74b9101bb4ab199dff6609fab44388c4a
Closes-Bug: 1574615
2016-05-18 11:42:07 +03:00
Mehdi Abaakouk 5dd059aa3c Remove deprecated localcontext
Change-Id: Ib109ced5ee6a706853b0f54be6756cfaf63e2164
2016-05-18 09:28:15 +02:00
Jenkins 3158d483f4 Merge "Refactor RPC client" 2016-05-16 14:22:11 +00:00
Gevorg Davoian 82602ae369 Refactor RPC client
The RPCClient class is fully based on the _CallContext class.
I think it is redundant to have the same attributes in the RPCClient
as in the _CallContext just in order to pass instances with these
attributes to the _CallContext._prepare method (which is not so obious
because it can work with both _CallContext and RPCCLient classes,
though these classes are not in the same class hierarchy).

This patch tries to solve all these issues by including both classes
in a hierarchy and to make a little optimization by eliminating
dummy _CallContext instances creation on each cast/call in RPCClient.

Change-Id: I608c828123b196099933d16801f8ce7d9dd3a079
2016-04-28 19:59:19 +03:00
Dmitriy Ukhlov 4df633db74 Improves exception handling and logging
1) try to catch all possible exceptions during message acknowledging
    and dispatching to send ack/nack when we can to do it
2) improve logging in case of exceptions during message acknowledging
    and dispatching

Depends-On: I2d230d49e5aff6ab4d84ab8c3d2834f85e3405eb
Change-Id: I41a768c5624fa2212257ce20bf9a67d09de0c4ab
2016-04-26 12:34:46 +00:00
Jenkins 84ed80eedd Merge "Update the RPC cast() documentation." 2016-04-22 17:08:04 +00:00
Kenneth Giusti 41dd8e3af3 Update the RPC cast() documentation.
Be explicit about the lack of ordering guarantees across sucessive
casts to the same destination.

Change-Id: I79927d27666331fc57e262562ead51168944ec1c
2016-04-22 10:57:21 -04:00
Dmitriy Ukhlov 6db00c77b0 Refactor base interfaces
1) Add MessageHandler base interface for on_incoming_callback replacement
2) Move message_handler parameter form Listener's __init__() to start()
3) Remove wait method from listener

Change-Id: Id414446817e3d2ff67b815074d042a9ce637ec24
2016-04-20 20:46:28 +00:00
Dmitriy Ukhlov 5d7d7253d1 Refactor driver's listener interface
Current Listener interface has poll() method which return messages

To use it we need have poller thread which is located in MessageHandlerServer
But my investigations of existing driver's code shows that some implemetations have
its own thread inside for processing connection event loop. This event loop received
messages and store in queue object. And then our poller's thread reads this queue
This situation can be improved. we can remove poller's thread, remove queue object
and just call on_message server's callback from connection eventloop thread

This path provide posibility to do this for one of drivers and leave as is other drivers

Change-Id: I3e3d4369d8fdadcecf079d10af58b1e4f5616047
2016-04-05 18:08:08 +00:00
Dmitriy Ukhlov 990d894eaf Move server related logic from dispatchers
Dispatcher should be responsible for routing message to the
callback method of endpoint object and returning result back to the
server only. But now it is also responsible for sending reply,
ack/reque messages etc.

Also this patch makes small improvements:
   1) Notification dispatcher now requeue message if endpoint raises exception
   2) unstable behaviour of test_mask_passwords test is fixed

Change-Id: I5f23e23644e90919cb67f81fc306ee85c5e09974
2016-03-30 11:07:32 +00:00
Jenkins f0d251d19d Merge "Missing version parameter in can_send_version()" 2016-03-17 07:06:02 +00:00