66 Commits

Author SHA1 Message Date
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
Nicolas Simonds
fcd51a67d1 Slow down Kombu reconnect attempts
For a rationale for this patch, see the discussion surrounding Bug

When reconnecting to a RabbitMQ cluster with mirrored queues in
use, the attempt to release the connection can hang "indefinitely"
somewhere deep down in Kombu.  Blocking the thread for a bit
prior to release seems to kludge around the problem where it is
otherwise reproduceable.

DocImpact

Change-Id: Ic2ede3046709b831adf8204e4c909c589c1786c4
Partial-Bug: 856764
2014-02-28 14:37:51 -08:00
Chet Burgess
0400cbf4f8 Gracefully handle consumer cancel notifications
With mirrored queues and clustered rabbit nodes a queue is still
mastered by a single rabbit node. When the rabbit node dies an
election occurs amongst the remaining nodes and a new master is
elected. When a slave is promoted to master it will close all the
open channels to its consumers but it will not close the
connections. This is reported to consumers as a consumer cancel
notification (CCN). Consumers need to re-subscribe to these queues
when they recieve a CCN.

kombu 2.1.4+ reports CCNs as channel errors. This patch updates
the ensure function to be more inline with the upstream kombu
functionality. We now monitor for channel errors as well as
connection errors and initiate a reconnect if we detect an error.

Change-Id: Ie00f67e65250dc983fa45877c14091ad4ae136b4
Partial-Bug: 856764
2014-02-28 14:22:26 -08:00
Jenkins
e9821fe602 Merge "Improve help strings" 2014-02-25 12:40:18 +00:00
Mehdi Abaakouk
0d102aa361 Abstract the acknowledge layer of a message
The patch add ta abstraction layer to acknowledge a message.

Partial implements blueprint notification-subscriber-server

Change-Id: I6e37780cc28737cfd56b6719ec8d9cebbc9bb278
2014-02-14 16:06:26 +01:00
Jenkins
5a48b027a0 Merge "RabbitMQ: advance thru the list of brokers on reconnect" 2014-02-10 03:24:47 +00:00
Jenkins
44d38cb15c Merge "Allow different login methods to be used with kombu connections" 2014-02-10 03:15:10 +00: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
Ihar Hrachyshka
71c6866471 RabbitMQ: advance thru the list of brokers on reconnect
In RabbitMQ implementation, when using multiple rabbit_hosts, we don't want to
immediately retry failed connection for the same failed broker. This was not
the case in existing implementation though, where we've always attempted to
reconnect starting from the first broker in the list of candidates. So if the
first broker failed, we initiated reconnect to the same failed broker.

This change makes reconnect() implementation to select the next broker in the
list. This also means that non-failure reconnect attempts will also switch the
current broker. All in all, users should not rely on any particular order to
use brokers from the list, so this should not constitute an issue.

Change-Id: I76965ea06c1fb6fd0cd384a5b3edc14703470b8f
Partial-Bug: 1261631
2014-02-05 15:28:33 +01:00
Jenkins
bf3896d462 Merge "Remove unused eventlet/greenlet from qpid/rabbit" 2014-02-04 20:25:32 +00:00
Jenkins
39ac6d37fe Merge "Fix UnboundLocalError error" 2014-02-01 10:54:57 +00:00
Joe Harrison
98454aaf86 Allow different login methods to be used with kombu connections
Currently it is not possible to modify the login method used with
kombu connections via configuration files, and requires modifying
the source code to actually add a login method in the first place.
This adds a configuration option (and default) which are passed
along to the kombu connection.

RabbitMQ allows three login method strings by default, but server
side plugins allow arbitrarily named strings to be used as login
methods and as such it is not possible to provide a fixed list of
options to the user.

DocImpact

Change-Id: I5c62a8dd4125d42bb429d3985061e37a9d519fff
Closes-Bug: #1269890
2014-01-29 01:11:24 +01:00
Ala Rezmerita
7295d8fdd2 Fix UnboundLocalError error
This change corrects the UnboundLocalError exception that
can occur if something bad happens on reconnect to RabbitMQ

Closes-Bug: #1272271

Change-Id: I9e157810caa7a45e9a61ec571cfe9024fabacf93
2014-01-24 12:06:03 +01:00
Andreas Jaeger
a5c7d6a2df Fix help strings
Use sentence style capitalization on help strings.

Change-Id: Ib3a8393eb0f3244d2ee431e71d3632195903b708
2014-01-18 16:16:19 +01:00
Jenkins
0fd4923e2f Merge "Fix try/except syntax for Python 3" 2014-01-11 07:36:30 +00: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
Mehdi Abaakouk
0218991a57 Remove unused eventlet/greenlet from qpid/rabbit
Because driver should rely on executor and not directly on eventlet,
delete eventlet/greenlet related code.

qpid/rabbit part.

Change-Id: I20a0850d54b6c6f81957beabb12f7d67f0c1e741
2013-12-19 16:35:57 +01:00
Victor Stinner
43e9d5fef5 Fix try/except syntax for Python 3
"except (IOError, errors):" fails with a TypeError if errors is a tuple on
Python 3, whereas it was accepted in Python 2.

Change-Id: I65cfb60af87e76fdf2d37043fb106adbd4586fb9
2013-12-19 14:56:49 +01:00
Mehdi Abaakouk
e57a15deb8 Remove eventlet related code in amqp driver
Because driver should rely on executor and not directly on eventlet,
delete eventlet related code. This also drop the old driver API.

This is the amqp part.

Change-Id: Ic6060058dafa4dabbc5e8c68bf231c818a7fec25
2013-12-16 17:30:36 +01:00
Chang Bo Guo
b38b3a3c13 Replace data structures' attribute with six module
In Python 3, some data structures' attribute is different in Python 2.
See http://pythonhosted.org/six/#object-model-compatibility
This is change mapping:

   six               Python 2           Python 3
six.next(it)         it.next()          next(it)
six.iterkeys(dict)   dict.iterkeys()    dict.keys()
six.itervalues(dict) dict.itervalues()  dict.values()

Implements: blueprint make-python3-compatible
Change-Id: Ida48f39ff230860feee7305b93b134c625a21663
2013-12-09 08:17:59 +00:00
Mehdi Abaakouk
42ce3ab4b5 Remove the partial implementation of ack_on_error
The ack_on_error is not used by the abstraction layer, and only the
rabbitmq implements it.

This commit remove this feature, and next commit will add a new way for
this.

Partial implements blueprint notification-subscriber-server

Change-Id: I17eb23f2e3e374630251576438011f186e5b2150
2013-12-05 13:49:35 +01:00