Commit Graph

49 Commits

Author SHA1 Message Date
Doug Hellmann 03265410e0 Remove oslo namespace package
Blueprint remove-namespace-packages

Depends-on: I2eeef93ee2e61a721c69f62add819f93f62f077d
for openstack/ceilometer
Depends-on: I26390dd908769be5f1a5b70be22d3b98e3a45563
for openstack/ceilometermiddleware
Depends-on: Ifa8baab33cdb3e606cf175a8c29c3a4ef6c44480
for openstack/glance
Depends-on: I029c3260051aa48cfaae428c096c1ac7b43b2bd2
for openstack/ceilometermiddleware

Change-Id: I8c5595bbafa82db33f62fa47d214f5cb756a2639
2015-07-16 17:47:16 +00: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
Jenkins 1949c7641d Merge "Add an optional executor callback to dispatcher" 2015-01-06 20:54:25 +00:00
Jenkins 3129701354 Merge "Don't allow call with fanout target" 2014-12-16 22:12:12 +00:00
Jenkins 85cd841ae7 Merge "Make the RPCVersionCapError message clearer" 2014-12-11 19:17:34 +00:00
Mehdi Abaakouk d3e6ea1788 Warns user if thread monkeypatch is not done
This change warns the user that it does have monkeypatched the
oslo.messaging library correclty.

Change-Id: Ice80ffc6cbc39919eac4bc0809992daea51b5922
Closes-bug: #1288878
2014-12-10 15:59:59 +01:00
Nikola Dipanov 4e6dabb698 Make the RPCVersionCapError message clearer
It is confusing to report that the version cap is too low, rather we
should report that the message version is too high.

Change-Id: Ic37eabb6f211fb68ca567ed4c400a1314e25cc68
2014-12-04 12:13:59 +01:00
Mehdi Abaakouk 09cd9c0fd3 Don't allow call with fanout target
Using call with a fanout target is an oddity.

This change removes that.

Closes bug: #1336759

Change-Id: I5d7dc8a6df72b910d67bbcdddd5256b6ad6ec73a
2014-12-03 15:41:27 +01:00
Victor Stinner 0844037fad Add an optional executor callback to dispatcher
The callback will be used in the new aiogreen executor to support
trollius coroutines.

The change includes an unit test.

Change-Id: I556b112371bec2ec29cea4dc254bb3f9c6d2c07a
2014-12-03 01:45:17 +01:00
Jenkins a1489a252d Merge "Track the attempted method when raising UnsupportedVersion" 2014-10-15 14:05:44 +00:00
Davanum Srinivas 487bbf5b13 Enable oslo.i18n for oslo.messaging
Change-Id: Ic8e05ae4ffe3eb871ae64243c41a9955f47cbe2a
2014-09-24 22:18:50 -04:00
armando-migliaccio ed886236f6 Track the attempted method when raising UnsupportedVersion
This helps in circumstances where the only stacktrace visible
is on the target side (e.g. due to cast or fanout operations)
and without the method information is difficult to root cause
what is going on.

Change-Id: I070ecda4d56186fcda8e8bfc49bf723928998393
Closes-bug: #1340277
2014-09-18 22:25:28 +00:00
Chris Dent ba5b547652 Fix error in example of an RPC server
Sample code in the documentation for rpc.server has an error which
prevents the code from being run. Replacing the `self` with `None`
results in code that runs. Whether it does anything useful is
an open question.

Change-Id: I81391fa3efdc65d54ca3aa155d63584f2b6f98c2
2014-08-06 15:03:53 +01:00
Christian Berendt 5be1b6a6a9 Enabled hacking checks H305 and H307
* H305  imports not grouped correctly
* H307  like imports should be grouped together

Change-Id: I08dafc4fa150d2213b2bb002da7c9ee0ee517fac
2014-07-17 12:41:21 +02:00
Christian Berendt 59103984bb Replaced 'e.g.' with 'for example'
According to the IBM Style Guide the Latin abbreviation 'e.g.'
should be replace by 'for example'.

Change-Id: I694df5ed62213e29bdf35f781fd6f310b7df77a6
2014-07-06 20:56:11 +02:00
Gauvain Pocentek 221144600a RPC server doc: use the blocking executor
The eventlet executor need additional code to make the RPC server sample
work. Using the blocking executor makes things easier to setup for a
newcomer.

Change-Id: I56dfa54a178962d4ced34e2f15eaf9312b7087cc
2014-06-22 09:48:33 +02:00
Christian Berendt 409108c74f replace string format arguments with function parameters
There are files containing string format arguments inside
logging messages. Using logging function parameters should
be preferred.

Change-Id: I4a7ce6916aefb2f2d445f0ebd977c824b1c51e24
Partial-Bug: #1321274
2014-06-20 14:18:40 +01:00
Jenkins 1b4d7ad6f2 Merge "Cleaned up references to executor specific RPCServer types" 2014-06-19 19:14:36 +00:00
Mark McLoughlin 2cdf9ec5ff Add an example usage of RPCClient retry parameter
Change-Id: Ib88870b312721deff0d9b6db2ba2e3cb99da6038
2014-06-13 15:42:00 +01:00
Mehdi Abaakouk 948c05417c Add transport reconnection retries
When a rpc client try to make a RPC call and the server is unreachable
The rpc call hang until the server come back.

In most case this is the desired behavior.

But sometimes, we can prefer that the library raise an exception after a
certain number of retries.

For example in ceilometer, when publishing a
storage.objects.incoming.bytes sample from the Swift middleware to an
AMQP topic, you might not want to block the Swift client if the AMQP broker
is unavailable - instead, you might have a queueing policy whereby
if a single reconection attempt fails we queue the sample in memory and
try again when another sample is to be published.

This patch is the oslo.messaging part that allow this.

Closes bug #1282639
Co-Authored-By: Ala Rezmerita <ala.rezmerita@cloudwatt.com>

Change-Id: I32086d0abf141c368343bf225d4b021da496c020
2014-06-13 16:21:59 +02:00
Ihar Hrachyshka 51c9b47c33 Cleaned up references to executor specific RPCServer types
In oslo.messaging design phase, it was planned to introduce executor
specific RPCServer types though they were never implemented. References
to those types sneaked into docstrings from the original design
document. Since we're not going to implement those types now, docstrings
should be updated accordingly.

Change-Id: Ic4017bb8f89d47115bb7dc59483e81d26c76212b
2014-05-26 14:39:53 +02:00
James Carey 8e38175938 Enable log messages to handle exceptions containing unicode
Currently the format string is a normal string, which in
py2x is not unicode.  When the unicode exception information is
used to replace the %s, str() is called on it, but because
it is unicode str() fails.  Making the format string unicode
fixes this.  For the error log this is done by making it
translatable and for the debug message by explicity making
it unicode.

The exception will contain unicode when the exception being
returned by the other project is either translated to a
language using unicode characters or when lazy translation
is enabled and a gettextutils.Message instance is returned.

Change-Id: I1706f5eb9dfbee434f8882b03dad4674d955c370
Closes-Bug: #1310397
2014-04-24 15:27:10 +00:00
ChangBo Guo(gcb) 3738bff165 Fix wrong parameter description in docstring
There is duplicated 'param' to same parameter, that should be 'type'.

Change-Id: I446a524ea27553e63c800f80edc5074df6e9c53b
2014-03-29 11:27:54 +08:00
Jenkins e9821fe602 Merge "Improve help strings" 2014-02-25 12:40:18 +00:00
Mehdi Abaakouk e785a5d994 Make the dispatcher responsible of the message ack
This patch make the dispatcher responsible of the message
acknowledgement.

This is the preliminar step to be able to requeue message.

Partial implements blueprint notification-subscriber-server

Change-Id: If74b47d5e23976d407deb27df7395b1982963c75
2014-02-18 08:31:30 +01:00
Mehdi Abaakouk 8a644c1166 Don't reply to notification message
The notification listener doesn't have anything to send to the notifier
and the notifier doesn't attend to receive something.

So this patch remove the message reply when the listener is a
notification
listener.

Partial implements blueprint notification-subscriber-server

Change-Id: Ic989947ba3b6894cde788422842fca19159ea261
2014-02-18 08:31:30 +01:00
Andreas Jaeger 5a860beb87 Improve help strings
Follow oslo.config style guide for help strings better to create
consistent help strings:
* Capitalize first word of each help string
* Finish help strings with "."

Change-Id: Ia08fa09593661e6e5b834d98bbd92689c2674075
2014-02-07 22:25:09 +01:00
Doug Hellmann 7b13bc1888 Update ExpectedException handling
Catch expected exceptions in a way that supports subclasses also being
seen as "expected."

Log a little more detail about unexpected exceptions in the ExecutorBase
so it is easier to add them to the list of expected exceptions.

Change-Id: I1bdd628eba717308f0afe1a889efd8711bad6296
Closes-bug: #1276163
2014-02-05 09:32:42 -08:00
Mehdi Abaakouk 86e5737bf6 Make the dispatcher responsible to listen()
The dispatcher is now responsible to configure and to get the listener from
the transport.

The server just ask to the dispatcher to build and return a configured
listener for a provider transport.

Partial implements blueprint notification-subscriber-server

Change-Id: I4a6d9620b8239f6d377bc5788b8a90a860b2f02c
2014-01-30 13:40:42 +01:00
Stanislav Kudriashev 2e59af91ba Fix spelling errors in comments
Change-Id: I9f7de85912c687d37661c3301b5898960082fc13
2014-01-10 17:02:27 +02:00
Victor Stinner 062c8ac7dd Replace dict.iteritems() with six.iteritems()
dict.iteritems() was replaced with dict.items() in Python 3. Use the
six.iteritems() function to get code compatible with Python 2 and Python 3.

Change-Id: I0c8ecc3ae540ffaf4c6b159e09ca16ccf365973d
2013-12-20 23:43:35 +01:00
Victor Stinner 2aaad74bac Fix syntax of relative imports for Python3
In Python 3, relative imports must be written "from .module import name":
http://docs.python.org/3.0/whatsnew/3.0.html#removed-syntax

Change-Id: I2ec8a7330e63ea64d291f2f37f0c01cdf765d4f7
2013-12-16 10:56:07 +01:00
Julien Danjou 97b9deca88 Remove useless global vars / import
This removes a few import and global variables that are not used through
the code. That cleans things a little.

Change-Id: I7b30bb11e8ad3c2df01ca2107eff2444feed3fe2
2013-12-02 15:26:53 +01:00
Mark McLoughlin 91f74d8df0 Fix rpc client docs
Missing a colon before the example code, see:

  http://docs.openstack.org/developer/oslo.messaging/rpcclient.html

Change-Id: Icd875e509b0057c2c739d43c11cd37ab923b59ee
2013-10-13 08:13:43 +01:00
Mark McLoughlin 1806c0724a Remove check_for_lock support in RPCClient
I added check_for_lock because I assumed it was enabled by default and
actively in use by Nova. However, it actually isn't used by Nova yet and
enabling spews a tonne of warnings.

It's a rather clunky API and there's a good chance we can design a
better API for it, so let's leave it out until we're ready to actually
start using it in Nova.

Related-Bug: #1063222
Change-Id: Ib890978398059f360cd0f3352f4755262b8111c6
2013-08-26 09:31:12 +01:00
Jenkins f3b30fde49 Merge "Add thread-local store of request context" 2013-08-12 09:23:42 +00:00
Mark McLoughlin f1612f2895 Add thread-local store of request context
Oslo's logging code has some useful support for including bits of the
request context in log messages. While this isn't exclusively about the
request context in a dispatching RPC method, it seems useful for
oslo.messaging to support the concept for at least this use case simply
by recording the context in a thread local store before dispatching an
endpoint method and immediately clearing it when the method returns.

Note, we don't need to store weak refs in our store because we will
clear the reference in all cases rather than ever leaving a stale
reference around in the store.

Change-Id: I70ac06ed3a2a891a7a7b388b1823a0f3b08f2dd1
2013-08-09 11:21:27 +01:00
Mark McLoughlin 2abb40f9e9 Add a context serialization hook
The client call() and cast() methods take a request context argument
which is expected to be a dictionary. The RPC endpoint methods on the
server are invoked with a dictionary context argument.

However, Nova passes a nova.context.RequestContext on the client side
and the oslo-incubator RPC code deserializes that as a amqp.RpcContext
which looks vaguely compatible with Nova's RequestContext.

Support the serialization and deserialization of RequestContext objects
with an additional (de)serialize_context() hook on our Serializer class.

Note: this is a backwards incompatible API change because Serializer
implementations which do not implement the new abstract methods would
no longer be possible to instantiate. Not a problem with this commit,
but shows the type of compat concerns we'll need to think about once the
API is locked down for good.

Change-Id: I20782bad77fa0b0e396d082df852ca355548f9b7
2013-08-09 08:24:49 +01:00
Mark McLoughlin bf171ede28 Document how call() handles remote exceptions
This is tricky stuff, so document it carefuly.

Related-Bug: #1162063
Change-Id: Id197bf87e9a7ed222508efe5d5246003ac02680e
2013-08-07 13:22:15 +01:00
Mark McLoughlin 66f597f30d Expose RemoteError exception in the public API
If a remote endpoint raises an exception which the client is not allowed
to (or cannot) deserialize, then RPCClient.call() raises a RemoteError
exception instead.

Make this exception type part of the public API.

Change-Id: I70be0ab7d40af3224d93d6bd0522c1a82f6303c3
2013-08-07 12:52:58 +01:00
Mark McLoughlin f6df32d943 Add API for expected endpoint exceptions
Review I4e7b19dc730342091fd70a717065741d56da4555 gives a lot of the
background here, but the idea is that some exceptions raised by an RPC
endpoint method do not indicate any sort of failure and should not be
logged by the server as an error.

The classic example of this is conductor's instance_get() method raising
InstanceNotFound. This is perfectly normal and should not be considered
an error.

The new API is a decorator which you can use with RPC endpoints methods
to indicate which exceptions are expected:

    @messaging.expected_exceptions(InstanceNotFound)
    def instance_get(self, context, instance_id):
        ...

but we also need to expose the ExpectedException type itself so that
direct "local" users of the endpoint class know what type will be used
to wrap expected exceptions. For example, Nova has an ExceptionHelper
class which unwraps the original exception from an ExpectedException and
re-raises it.

I've changed from client_exceptions() and ClientException to make it
more clear it's intent. I felt that the "client" naming gave the
impression it was intended for use on the client side.

Change-Id: Ieec4600bd6b70cf31ac7925a98a517b84acada4d
2013-08-07 12:52:54 +01:00
Mark McLoughlin 837aa03c43 Include docstrings in published docs
Change-Id: Icdfb0535b26162d39c3af683b7729b5e834d89b9
2013-07-10 09:33:13 +01:00
Mark McLoughlin 03aafcb49c Simplify public symbol exports
Inspired by tulip, have every module define a __all__ list and import *
from the top-level module.

Rename transport.set_defaults() since we don't want this to be a
top-level set_defaults() function as there may be multiple.

Also, rather than configuring flake8 to allow star imports, just exclude
the __init__.py files from flake8 checks.
2013-06-24 12:52:30 +01:00
Mark McLoughlin e67f409b87 Don't use common logging
It appears we don't actually need this - we don't, for example, use any
of the special formatting supported by ContextAdaptor.
2013-06-16 15:24:41 +01:00
Mark McLoughlin fd68391d53 Use log.warning() instead of log.warn()
warn() is provided by ContextAdapter, there's no reason to use it.
2013-06-16 12:00:09 +01:00
Mark McLoughlin 293a34c156 Add can_send_version() to RPCClient
Add a helper method to the RPCClient class.  This is a little nicer to
use for checking to see if a given message is copmatible with the set
version cap.

This can be used in a bunch of different ways:

  client = RPCClient(version_cap='1.6', version='1.0')
  client.can_send_version()
  client.can_send_version(version='1.6')

  client = client.prepare(version_cap='1.8', version='1.5')
  client.can_send_version()
  client.can_send_version(version='1.2')

Co-authored-by: Russell Bryant <rbryant@redhat.com>
2013-06-16 09:39:09 +01:00
Mark McLoughlin 1ab3b83f43 Don't raise a driver-specific error on send
Similar to doing listen() on the server side, if the driver throws an
exception when we do a cast() or call() we should translate it into
a transport-agnostic exception.
2013-06-15 19:24:32 +01:00
Mark McLoughlin 8a8685b62f Make it possible to call prepare() on call context
Found it's quite easy to get into doing e.g.

  client = RPCClient(...)
  client = client.prepare(topic='foo')
  client = client.prepare(server='bar')
2013-06-15 18:56:15 +01:00
Mark McLoughlin cbfb1452a4 Move files to new locations for oslo.messaging 2013-06-15 08:43:54 +01:00