37 Commits

Author SHA1 Message Date
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
Javeme
89bc0e6ef2 Missing version parameter in can_send_version()
Change-Id: I1afadaabe908df4d66c94d36539c7380e424c186
Closes-Bug: #1554996
2016-03-15 13:04:19 +08:00
Joshua Harlow
0774b5ceba Always delete exc_info tuple, even if reply fails
Avoid any possible references to exc_info tuple by ensuring
we delete it in a finally block, so that even if replying or
logging fails somehow the prior exception is always deleted
correctly.

Change-Id: Id0e5099b9b38b1803bb4514f7cf3deae760d5ac3
2016-03-04 11:52:34 -08:00
Victor Stinner
22fea728cc Remove executor callback
Revert the change I556b112371bec2ec29cea4dc254bb3f9c6d2c07a: the
executor callback API was only used by the aioeventlet executor which
was just removed.

Change-Id: I1223f32594d8c1be28cc43fdd9bf102c86d75325
2016-02-18 12:50:44 +01:00
Jenkins
213176657d Merge "batch notification listener" 2015-12-11 04:16:57 +00:00
Jenkins
4b6144a3db Merge "creates a dispatcher abstraction" 2015-12-10 11:15:48 +00:00
Mehdi Abaakouk
185693a6ed Improves comment
Change-Id: Idc8002e6d622435aac48304857985c0f82be3e32
2015-12-09 11:23:52 +01:00
Mehdi Abaakouk
4dd644ac20 batch notification listener
Gnocchi performs better if measurements are write in batch
When Ceilometer is used with Gnocchi, this is not possible.

This change introduce a new notification listener that allows that.

On the driver side, a default batch implementation is provided.
It's just call the legacy poll method many times.

Driver can override it to provide a better implementation.
For example, kafka handles batch natively and take benefit of this.

Change-Id: I16184da24b8661aff7f4fba6196ecf33165f1a77
2015-12-08 09:14:20 +01:00
Mehdi Abaakouk
bdf287e847 creates a dispatcher abstraction
This change creates a dispatcher abstraction
to document the interface of a dispatcher.

And also allows in the futur to have attributes with default values.

Change-Id: I9a7e5e03f89635a3790b3851f492a1a7aab58feb
2015-12-07 16:43:34 +01:00
Mehdi Abaakouk
cc97ba2e17 doc: explain rpc call/cast expection
This change adds some doc about remote method execution expectation
when rpc call/cast is used.

Change-Id: Idb26413fc9a6747ebcd6fd32b82f63ea97bfae16
2015-12-01 15:50:50 +01:00
BANASHANKAR KALEBELAGUNDI VEERA
33243c26ac Fixing the server example code
Added server.stop() before server.wait()

Change-Id: I9764c77e0aa076b6a7b9bb9715e2ead89b12126f
2015-11-10 14:58:17 -08:00
Daisuke Fujita
64fb61d37c Fix typo in rpc/server.py and notify/listener.py
1. "messaging configuration configuration" to "messaging configuration"

Change-Id: Icda5d2df67cc4d2d0e0cb3a453d0b04dd998e5f4
2015-10-09 22:20:51 +09:00
Davanum Srinivas
588d795b3c Use proper translating helper for logging
Add hacking rule borrowed from keystone to make sure
we don't regress and fix all the issues found by the
hacking check.

Change-Id: I41635fdd83c3e04d04f9849a72c49ccb5ac42875
2015-08-20 21:01:59 -04:00
Jenkins
0969bfcd89 Merge "Verify that version in 'prepare' is valid" 2015-07-13 11:01:24 +00:00
Mehdi Abaakouk
c49594a62f Remove usage of contentmanager for executors
The context manager in the executor fit only for the blocking executor.
Even the dispatcher needs to run code before and after the application
callback, eventlet and future executors have to run the pre/post code
into the main thread and can run the callback into an other thread,
and that force them to run __enter__ and __exit__ manually and deal
the exception path.

This change adds a helper object instead of the context manager.
It is designed to be explicit on what must be executed
before and after the callback and what can be done in a thread or not.

All the executor code is now in the impl_pooledexecutor.py
and use the futures "PoolExecutor" API.

This use futurist to provide a eventlet and aioeventlet futures friendly
object.

Change-Id: I8cd7640f36beeda47560e3c82671bad3530e38d1
2015-07-08 13:42:10 +02:00
Kevin Benton
ac57114c2d Verify that version in 'prepare' is valid
Raise an exception if a caller passes a something for the
version that cannot be parsed as a version.

Change-Id: I167849b1bc6c4d946de42c6459b3577a361e9606
Related-Bug: #1467087
2015-07-07 07:34:12 -07:00
Corey Wright
8422e975b3 Correct RPCVersionCapError message
This change adjusts the exception message to be more in line with the
version compatibility algorithm so as to accurately portray the
problem to the log recipient.

The RPCVersionCapError message can be grossly incorrect when the
requested message's major version is lower than the specified version
cap's major version, declaring the requested message version as too
high, when the real error is that the major versions differ (as major
versions are assumed to be incompatible).

Example:

    RPCVersionCapError: Requested message version, 3.23 is too
    high. It needs to be lower than the specified version cap 4.0.

Change-Id: Iceef999ed385f2ba77449c568127f50f83d47196
Closes-Bug: 1468525
2015-06-24 17:18:46 -05:00
Jenkins
be764f18d4 Merge "Add support for multiple namespaces in Targets" 2015-03-13 11:38:25 +00:00
Assaf Muller
3be95adceb Add support for multiple namespaces in Targets
In order for projects to use the namespace property of Targets
in a backwards compatible way (To support rolling upgrades),
a Target may now belong to more than a single namespace (i.e.
'namespace1' and None). This way, if the server is upgraded first,
the version that introduces namespaces to a project will place
the server RPC methods in ['some_namespace', None]. Pre-upgrade
agents will send messages in the null namespace while post-upgrade
agents will send messages in 'some_namespace', and both will be
accepted.

Change-Id: I713fe9228111c36aa3f7fb95cbd59c99100e8c96
Closes-Bug: #1430984
2015-03-12 16:07:51 -04:00
Mehdi Abaakouk
01247563f1 Deprecates the localcontext API
We deprecate the localcontext API in favor of the
oslo.context one.

Related bug: #1288878

Change-Id: If6049544e35ae49e41f2771cae858b6d4ebe00cd
2015-03-11 16:14:50 +01:00
Doug Hellmann
ee31a84719 Update Oslo imports to remove namespace package
Change-Id: I4ec9b2a310471e4e07867073e9577731ac34027d
Blueprint: drop-namespace-packages
2015-01-21 21:09:33 -05:00
Doug Hellmann
e55a83e832 Move files out of the namespace package
Move the public API out of oslo.messaging to oslo_messaging. Retain
the ability to import from the old namespace package for backwards
compatibility for this release cycle.

bp/drop-namespace-packages

Co-authored-by: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
Change-Id: Ia562010c152a214f1c0fed767c82022c7c2c52e7
2015-01-12 12:50:41 -05:00