Commit Graph

86 Commits

Author SHA1 Message Date
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 8102f25dd2 Merge "Fix some comments in a backporting review session" 2015-01-08 19:23:39 +00:00
Mehdi Abaakouk 31a149a4df Add a info log when a reconnection occurs
This change adds a info log when a reconnection occurs
like we have before.

Change-Id: I3b7d86894efac09e27125c368fc83e83c36b630e
2015-01-07 21:30:22 +00:00
Jie Li 3e2d142a87 Fix some comments in a backporting review session
* add i18n support to some exception messages
  * remove the return value of DecayingTimer.start()

Relates to review: I898a236a384b3466147026abc7a1ee21801e8ca1

Change-Id: I7adf5478732f1f46db1009b059b66ff8af6ecdc3
2014-12-27 12:01:25 +08:00
Mehdi Abaakouk 15aa5cbda8 The executor doesn't need to set the timeout
It's up to the driver to set a suitable timeout for polling the broker,
this one can be different that the one requested by the driver
caller as long as the caller timeout is respected.

This change also adds a new driver listener API, to be able
to stop it cleanly, specially in case of timeout=None.

Closes bug: #1400268
Closes bug: #1399257
Change-Id: I674c0def1efb420c293897d49683593a0b10e291
2014-12-08 12:59:33 +01:00
Mehdi Abaakouk 023b7f44e2 rabbit: more precise iterconsume timeout
The iterconsume always set the timeout of kombu to 1 second
even the requested timeout more precise or < 1 second.

This change fixes that.

Related bug: #1400268
Related bug: #1399257

Change-Id: I157dab80cdb4afcf9a5f26fa900f96f0696db502
2014-12-08 12:08:01 +01:00
Jenkins a7f3ecb360 Merge "Touch up grammar in warning messages" 2014-12-05 09:58:33 +00:00
Jenkins d2105f61f8 Merge "Add more TLS protocols to rabbit impl" 2014-12-04 22:18:09 +00:00
Jenkins 1834167b4f Merge "Warn user if needed when the process is forked" 2014-12-04 21:47:03 +00:00
Doug Hellmann 66db2b310d Touch up grammar in warning messages
Change-Id: I556e6e646417be3732a7c31987ec964f9808f079
2014-12-04 16:04:37 -05:00
Jenkins bf9fd263f9 Merge "Fix reconnect race condition with RabbitMQ cluster" 2014-12-04 14:52:28 +00:00
Mehdi Abaakouk 712f6e3c5e Reintroduces fake_rabbit config option
This change reintroduces the fake_rabbit only for backward compatibility,
but mark it as deprecated.

Now, to use the kombu in-memory driver (that is not thread safe) we must
set the transport_url config option to 'kombu+memory:////" or the
rpc_backend to kombu+memory.

Or we can use the fake driver of oslo.messaging by setting the
transport_url to 'fake:///' or the rpc_backend to 'fake'

This is effectively reverting commit bcb3b23b8f.

Closes-bug: #1399085

Change-Id: I7b6fb3811fc6f695f75ecd350e04e69afd26c428
2014-12-04 11:54:58 +00:00
Mehdi Abaakouk 2dd7de989f Rabbit: iterconsume must honor timeout
The iterconsume method of the rabbit driver must
honor timeout parameter when reconnection to the broker
occurs.

Change-Id: I666d818449750c6bae9dde02f519842687a8e4fa
2014-12-02 14:42:04 +01:00
Mehdi Abaakouk bcb3b23b8f Don't use oslo.cfg to set kombu in-memory driver
This removes a TODO and also fixes a issue due to the
global state of oslo.config.cfg.CONF.

Closes bug: #1397339

Change-Id: Ib366f35678f899fda93821e6f07897baf8f631b4
2014-12-02 14:42:04 +01:00
Mehdi Abaakouk f3370da11a Don't share connection pool between driver object
Each driver instance must use it's own connection pool.

This removes the last global state of qpid and rabbitmq driver
Make the relation between classes more simple.

The previous behavior was not very safe, as explained in the bug report.

And also, this is a first step to replace this custom connection pool
handling by the kombu one.

Closes bug: #1397925
Partial bug: #1397339

Change-Id: Iecd2b39c76417d9ac081d46810f72eb6e38edfda
2014-12-02 08:26:17 +01:00
Mehdi Abaakouk eb21f6b263 Warn user if needed when the process is forked
This change warns the library consumer when the process if forked and
we can't be sure that the library work as expected.

This also add some documentation about forking oslo.messaging Transport
object.

Change-Id: I2938421775aa72866adac198d70214856d45e165
Related-bug: #1330199
2014-11-27 16:29:20 +01:00
Jens Rosenboom 7ad0d7eaf9 Fix reconnect race condition with RabbitMQ cluster
Retry Queue creation to workaround race condition
that may happen when both the client and broker race over
exchange creation and deletion respectively which happen only
when the Queue/Exchange were created with auto-delete flag.

Queues/Exchange declared with auto-delete instruct the Broker to
delete the Queue when the last Consumer disconnect from it, and
the Exchange when the last Queue is deleted from this Exchange.

Now in a RabbitMQ cluster setup, if the cluster node that we are
connected to go down, 2 things will happen:

 1. From RabbitMQ side, the Queues w/ auto-delete will be deleted
    from the other cluster nodes and then the Exchanges that the
    Queues are bind to if they were also created w/ auto-delete.
 2. From client side, client will reconnect to another cluster
    node and call queue.declare() which  create Exchanges then
    Queues then Binding in that order.

Now in a happy path the queues/exchanges will be deleted from the
broker before client start re-creating them again, but it also
possible that the client first start by creating queues/exchange
as part of the queue.declare() call, which are no-op operations
b/c they alreay existed, but before it could bind Queue to
Exchange, RabbitMQ nodes just received the 'signal' that the
queue doesn't have any consumer so it should be delete, and the
same with exchanges, which will lead to binding fail with
NotFound error.

Illustration of the time line from Client and RabbitMQ cluster
respectively when the race condition happen:

       e-declare(E)      q-declare(Q)       q-bind(Q, E)
     -----+------------------+----------------+----------->
                               e-delete(E)
     ------------------------------+---------------------->

Change-Id: Ideb73af6f246a8282780cdb204d675d5d4555bf0
Closes-Bug: #1318721
2014-11-27 13:49:52 +01:00
Brant Knudson 1624793088 Add more TLS protocols to rabbit impl
Python 2.7.9 added PROTOCOL_TLSv1_1 and PROTOCOL_TLSv1_2, so these
are added to the allowed kombu_ssl_version values.

See https://docs.python.org/2/library/ssl.html#ssl.PROTOCOL_TLSv1_1

Change-Id: I1dd590d916ab524284a941db91b9cb81fd4639bb
2014-11-25 10:59:05 -06:00
Thomas Goirand 42f55a1dda Remove the use of PROTOCOL_SSLv3
The PROTOCOL_SSLv3 should not be used, as it can be exploited with
a protocol downgrade attack. Also, its support has been removed in
Debian, so it simply doesn't work at all now in Sid.

This patch removes PROTOCOL_SSLv3 from one of the possible protocols
used by oslo.messaging.

Closes-Bug: #1395095
Change-Id: I2c1977c3bfc1923bcb03744e909f2e70c7fdb14c
2014-11-25 10:47:16 -06:00
Mehdi Abaakouk 973301aa70 rabbit: uses kombu instead of builtin stuffs
The rabbit driver have a custom code to reconnect to a broker,
to change the broker in HA configuration, to retry a to send
a message, to handle the interval between reconnection.

But all of that exists in kombu, so just use it.

Using the kombu Connection object with the url make also the rabbit
driver more generic.

Futher patches can rename rabbit* oslo.config options to a more generic
name and add a new driver entry_point 'kombu' to allow to use this driver
with any borker supported by kombu.

Change-Id: Id6b89d5448126ca652b46fe6ce5a9b3ed5839795
2014-11-19 17:21:02 +01:00
Davanum Srinivas 487bbf5b13 Enable oslo.i18n for oslo.messaging
Change-Id: Ic8e05ae4ffe3eb871ae64243c41a9955f47cbe2a
2014-09-24 22:18:50 -04:00
Jenkins ac74be3c80 Merge "Improve help strings" 2014-09-08 15:24:39 +00:00
Andreas Jaeger 7c2853a92c Improve help strings
Follow oslo.config conventions for consistency of help strings:
* Use sentence style capitalization.
* End entry with a "."
Fix capitalization of AMQP.

Change-Id: I0a6b170a2a7cfa539e06781f4495c4353d22e4d0
2014-08-28 06:59:33 +02:00
Julien Danjou a9ec73f38d Switch to oslo.utils
Change-Id: I262e98d8d03acbe2ff8fee5d607279a669a89e34
2014-08-27 14:14:00 +02:00
Jenkins a9ce3529de Merge "Replace lambda method _" 2014-08-26 22:58:41 +00:00
Julien Danjou 4cb33ecc94 Port to Python 3
This patch enables running all the unit tests (except the qpid ones that
are skipped) under Python 3.3 and Python 3.4.

Change-Id: I711663b4eedfb3cdeea7e6da7d28c6b92663e611
2014-08-18 17:08:13 +02:00
Christian Berendt 7fdeddaa3b Replace lambda method _
Instead of the lambda method _ the method should be imported
from oslo.messaging.openstack.common.gettextutils.

Change-Id: I373337cc1227b0d7b7bf93603b53a64de83721a9
2014-08-04 14:25:33 +02: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
Aaron Rosen 0102aa96e6 Replace usage of str() with six.text_type
Replace using of str with six.text_type as it's able to
handle unicode data.

Change-Id: I38e4378c490d1dad8020312308dd3b6dad8772c0
2014-06-25 20:08:51 +00:00
ChangBo Guo(gcb) 821ee096a6 Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this.

Change-Id: I67cc0774a65886ef9fce0b72e52157b622248a85
Closes-Bug: #1327473
2014-06-21 11:41:36 +08: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
Mehdi Abaakouk 1ea9c35ab4 Transport reconnection retries for notification
This patch add support of reconnection retries for the
messaging notifier.

Related bug #1282639
Change-Id: Ia30331f8306ff0f6952d83ef42ff8bee6b900427
2014-06-18 18:41:33 +02:00
Aaron Rosen bf281aace5 Add check credentials to log message if rabbmitmq closes socket
If one has the credentials misconfigured for rabbitmq currently the following
error message is shown: "AMQP server on 10.0.0.23:5672 is unreachable:
Socket closed. Trying again in 1 seconds. " This is confusing because the
problem is the login creditentials are wrong but the server can be reached.

Since the rabbmitmq server allowed the initial connection and closed the
socket it's likely an authenication issue. This patch now logs: "AMQP server
10.0.0.23:5672 closed the connection. Check login credentials: Socket closed"
to hint the user that it could be a credential issue.

Change-Id: Iadff35d88a9cf704c1edd2d5036a113966db3ea3
Closes-bug: 1325750
2014-06-16 17:03:15 -07:00
Mark McLoughlin d7b85a1492 rabbit/qpid: remove the args/kwargs from ensure()
Having an *args list following the retry kwargs just screams:

  SyntaxError: non-keyword arg after keyword arg

but we don't actually pass any args to methods invoked via ensure() so
these are just unused and can be removed. If we did want them in future
we could just use functools.partial().

Change-Id: Idef12bbc94d39c84ee06ddd6d743f3d2f705a8d1
2014-06-13 16:16:18 +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
Mehdi Abaakouk f4da213539 Remove amqp default exchange hack
This change remove the hack to set the default exchange of a transport in the
amqp driver, by removing the usage of the configuration object to get the
default exchange in rabbit and qpid driver, and instead use the value
passed to the driver constructor into all amqp publishers and consumers
class/method that needs it.

Closes-bug: #1256345
Change-Id: Iba54ca79a49f8545854205c1451b2403735c1006
2014-05-28 14:12:30 +02:00
Christian Berendt a6200c0a00 debug level logs should not be translated
According to the OpenStack translation policy available at
https://wiki.openstack.org/wiki/LoggingStandards debug messages
should not be translated. Like mentioned in several changes in
Nova by garyk this is to help prioritize log translation.

Change-Id: I4af4a45a56b1364a2f5196b75cff299d607ab393
Partial-Bug: #1317950
2014-05-20 22:57:36 +02:00
Jenkins 17375f41ce Merge "Full support of multiple hosts in transport url" 2014-05-05 15:46:34 +00:00
ChangBo Guo(gcb) 23edc1b4ce Remove str() from LOG.* and exceptions
gettextutils is expecting to receive unicode strings
rather than basestrings. A basestring can cause an
unhandled exception in the logging code. To help avoid
such issues we should remove str() from LOG.* messages and
exceptions. We have verified that the %s formatting code
properly handle getting strings to unicode where necessary.

Copied from https://review.openstack.org/#/c/77722

Change-Id: I082af5c9ae8bf9859382c2c387b10b48358e10b3
Related-Bug: #1286306
2014-04-27 10:21:21 +08:00
Mehdi Abaakouk 53b9d741a8 Full support of multiple hosts in transport url
This patch add the support of multiple hosts in transport url for rabbit and
qpid drivers. And also fix the amqp connection pool management to allow
to have one pool by transport.

Implements blueprint multiple-hosts-support-in-url

Co-Authored-By: Ala Rezmerita <ala.rezmerita@cloudwatt.com>
Change-Id: I5aff24d292b67a7b65e33e7083e245efbbe82024
2014-04-22 17:02:52 +02:00
Jenkins 7daba8ab90 Merge "Remove rendundant parentheses of cfg help strings" 2014-04-17 05:01:18 +00:00
ChangBo Guo(gcb) 8ae1880f7a Select AMQP message broker at random
The rule of choosing AMQP message broker is that chose first
available one in order now. The order depends on what we set in
configuration file. That means all the connections will flock
to same message broker and that may lead out performance issue.
This patch randomizes the order of choosing message broker for
each connection to leverage broker cluster.

Change-Id: Ib5098e574d4ef81428065885e2295d0f87aba715
Partial-Bug: #1261631
2014-04-12 16:45:29 +08:00
ChangBo Guo(gcb) 9719b8a57b Remove rendundant parentheses of cfg help strings
There is a hacking review https://review.openstack.org/#/c/74493/.
That makes me be aware we maybe have rendunant parentheses.
We'd better clean the parentheses, Python will handle that well.

Change-Id: Ib29f995feed45d71000f333a2cc7d14b0efcb0d5
2014-04-03 17:27:48 +08:00
ChangBo Guo(gcb) af72ad9a92 Refactor AMQP message broker selection
Drop redundant variable, make code more clean.

Partial-Bug: #1261631

Change-Id: I5fd71ce3bcd3a82839204ee1fb130de3a3e1d3ac
2014-03-22 15:47:59 +08:00
Jenkins 543d5f06bb Merge "Remove use of sslutils" 2014-03-04 18:42:48 +00:00
Mark McLoughlin 3eeaaee788 Remove use of sslutils
sslutils is the only oslo-incubator module we use which registers any
config options, and we don't even use those config options at runtime.

The problem with us using oslo-incubator config options is that they
need to be exactly in sync with the oslo-incubator version of those
used by every project using oslo.messaging.

Avoid all this be inlining validate_ssl_version() until we have it
available in a real library.

Change-Id: Id3b0bb2e7ede33ede9b66025d1af113ae60cfc58
Closes-Bug: #1287542
2014-03-04 06:23:35 -08:00
Jenkins 491414408b Merge "Slow down Kombu reconnect attempts" 2014-03-04 04:33:25 +00:00
Jenkins 5594a57012 Merge "Gracefully handle consumer cancel notifications" 2014-03-04 04:33:24 +00:00
Mark McLoughlin 5bd31315c2 notification listener: add allow_requeue param
In commit d8d2ad9 we added support for notification listener endpoint
methods to return REQUEUE, but if a driver does not support this we
raise NotImplementedError when the application attempts to requeue
a message.

This requeuing behaviour might only be used by an application in
unusual, exceptional circumstances and catch users by surprise.

Instead, let's require the application to assert that it needs this
feature in advance and raise NotImplementError at that point if the
driver doesn't support it.

Change-Id: Id0bb0e57d2dcc1ec7d752e98c9b1e8e48d99f35c
2014-03-03 07:51:18 -08:00
Mehdi Abaakouk d8d2ad95d7 Allow to requeue the notification message
This patch allow to requeue the notification received by the
notification listener.

Partial implements blueprint notification-subscriber-server

Change-Id: I49c4ba91224c280e479edb19289ccb337a2ab843
2014-03-03 09:27:57 +01:00