[python-oslo-messaging/f21] Updated patches from f21-patches

Alan Pevec apevec at fedoraproject.org
Tue Aug 19 09:16:29 UTC 2014


commit fa33c155ada14f0742dc5e768bb6a409660e03ba
Author: Alan Pevec <alan.pevec at redhat.com>
Date:   Tue Aug 19 11:15:15 2014 +0200

    Updated patches from f21-patches

 ...redentials-to-log-message-if-rabbmitmq-cl.patch |   46 +++++
 ...the-notify-method-of-the-routing-notifier.patch |  198 ++++++++++++++++++++
 python-oslo-messaging.spec                         |    6 +
 3 files changed, 250 insertions(+), 0 deletions(-)
---
diff --git a/0001-Add-check-credentials-to-log-message-if-rabbmitmq-cl.patch b/0001-Add-check-credentials-to-log-message-if-rabbmitmq-cl.patch
new file mode 100644
index 0000000..bdd81d4
--- /dev/null
+++ b/0001-Add-check-credentials-to-log-message-if-rabbmitmq-cl.patch
@@ -0,0 +1,46 @@
+From 312abc586435667f28bb98fa8a1183476b4aabb7 Mon Sep 17 00:00:00 2001
+From: Aaron Rosen <aaronorosen at gmail.com>
+Date: Mon, 2 Jun 2014 14:37:30 -0700
+Subject: [PATCH] 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
+(cherry picked from commit bf281aace507dec7547e40f68d8cd7bb290dc903)
+(cherry picked from commit faf2b699b340634b904cdd8590b271b4b1862bf1)
+---
+ oslo/messaging/_drivers/impl_rabbit.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/oslo/messaging/_drivers/impl_rabbit.py b/oslo/messaging/_drivers/impl_rabbit.py
+index 5b6cf03..fa2b767 100644
+--- a/oslo/messaging/_drivers/impl_rabbit.py
++++ b/oslo/messaging/_drivers/impl_rabbit.py
+@@ -611,9 +611,14 @@ class Connection(object):
+                 sleep_time = min(sleep_time, self.interval_max)
+ 
+             log_info['sleep_time'] = sleep_time
+-            LOG.error(_('AMQP server on %(hostname)s:%(port)d is '
+-                        'unreachable: %(err_str)s. Trying again in '
+-                        '%(sleep_time)d seconds.') % log_info)
++            if 'Socket closed' in six.text_type(e):
++                LOG.error(_('AMQP server %(hostname)s:%(port)d closed'
++                            ' the connection. Check login credentials:'
++                            ' %(err_str)s') % log_info)
++            else:
++                LOG.error(_('AMQP server on %(hostname)s:%(port)d is '
++                            'unreachable: %(err_str)s. Trying again in '
++                            '%(sleep_time)d seconds.') % log_info)
+             time.sleep(sleep_time)
+ 
+     def ensure(self, error_callback, method, *args, **kwargs):
diff --git a/0002-Fix-the-notify-method-of-the-routing-notifier.patch b/0002-Fix-the-notify-method-of-the-routing-notifier.patch
new file mode 100644
index 0000000..2f9fb44
--- /dev/null
+++ b/0002-Fix-the-notify-method-of-the-routing-notifier.patch
@@ -0,0 +1,198 @@
+From 79ea459a228aa00eef5d21538f7dfdb360a016b8 Mon Sep 17 00:00:00 2001
+From: Mehdi Abaakouk <mehdi.abaakouk at enovance.com>
+Date: Tue, 6 May 2014 18:24:49 +0200
+Subject: [PATCH] Fix the notify method of the routing notifier
+
+The notify method of the routing notifier don't have the correct
+signature and change the case of the priority.
+
+This change fixes it.
+
+Change-Id: I833b19d0c054c94b861a4f6cc263c3487fa0e544
+Closes-bug: #1316681
+(cherry picked from commit cbbb90e28c608d165df94b779c04593bd17d02f1)
+(cherry picked from commit b3a5648e608401341e673f4e9b9ca910eccd7dc9)
+---
+ oslo/messaging/notify/_impl_routing.py | 18 +++++-----
+ tests/test_notifier.py                 | 66 +++++++++++++++++++++++++++-------
+ 2 files changed, 62 insertions(+), 22 deletions(-)
+
+diff --git a/oslo/messaging/notify/_impl_routing.py b/oslo/messaging/notify/_impl_routing.py
+index 5b32cd0..21c9ba5 100644
+--- a/oslo/messaging/notify/_impl_routing.py
++++ b/oslo/messaging/notify/_impl_routing.py
+@@ -104,33 +104,31 @@ class RoutingDriver(notifier._Driver):
+ 
+         return list(accepted_drivers)
+ 
+-    def _filter_func(self, ext, context, message, accepted_drivers):
++    def _filter_func(self, ext, context, message, priority, accepted_drivers):
+         """True/False if the driver should be called for this message.
+         """
+         # context is unused here, but passed in by map()
+         return ext.name in accepted_drivers
+ 
+-    def _call_notify(self, ext, context, message, accepted_drivers):
++    def _call_notify(self, ext, context, message, priority, accepted_drivers):
+         """Emit the notification.
+         """
+         # accepted_drivers is passed in as a result of the map() function
+         LOG.info(_("Routing '%(event)s' notification to '%(driver)s' driver") %
+                  {'event': message.get('event_type'), 'driver': ext.name})
+-        ext.obj.notify(context, message)
++        ext.obj.notify(context, message, priority)
+ 
+-    def notify(self, context, message):
++    def notify(self, context, message, priority):
+         if not self.plugin_manager:
+             self._load_notifiers()
+ 
+         # Fail if these aren't present ...
+         event_type = message['event_type']
+-        priority = message['priority'].lower()
+ 
+         accepted_drivers = set()
+         for group in self.routing_groups.values():
+-            accepted_drivers.update(self._get_drivers_for_message(group,
+-                                                                  event_type,
+-                                                                  priority))
+-
++            accepted_drivers.update(
++                self._get_drivers_for_message(group, event_type,
++                                              priority.lower()))
+         self.plugin_manager.map(self._filter_func, self._call_notify, context,
+-                                message, list(accepted_drivers))
++                                message, priority, list(accepted_drivers))
+diff --git a/tests/test_notifier.py b/tests/test_notifier.py
+index 40733c0..75edc78 100644
+--- a/tests/test_notifier.py
++++ b/tests/test_notifier.py
+@@ -13,6 +13,7 @@
+ #    License for the specific language governing permissions and limitations
+ #    under the License.
+ 
++import contextlib
+ import datetime
+ import logging
+ import sys
+@@ -20,6 +21,7 @@ import uuid
+ 
+ import fixtures
+ import mock
++from stevedore import dispatch
+ from stevedore import extension
+ import testscenarios
+ import yaml
+@@ -27,7 +29,6 @@ import yaml
+ from oslo import messaging
+ from oslo.messaging.notify import _impl_log
+ from oslo.messaging.notify import _impl_messaging
+-from oslo.messaging.notify import _impl_routing as routing
+ from oslo.messaging.notify import _impl_test
+ from oslo.messaging.notify import notifier as msg_notifier
+ from oslo.messaging.openstack.common import jsonutils
+@@ -304,7 +305,11 @@ class TestLogNotifier(test_utils.BaseTestCase):
+ class TestRoutingNotifier(test_utils.BaseTestCase):
+     def setUp(self):
+         super(TestRoutingNotifier, self).setUp()
+-        self.router = routing.RoutingDriver(None, None, None)
++        self.config(notification_driver=['routing'])
++
++        transport = _FakeTransport(self.conf)
++        self.notifier = messaging.Notifier(transport)
++        self.router = self.notifier._driver_mgr['routing'].obj
+ 
+     def _fake_extension_manager(self, ext):
+         return extension.ExtensionManager.make_test_instance(
+@@ -380,22 +385,22 @@ group_1:
+         # No matching event ...
+         self.assertEqual([],
+                          self.router._get_drivers_for_message(
+-                             group, "unknown", None))
++                             group, "unknown", "info"))
+ 
+         # Child of foo ...
+         self.assertEqual(['rpc'],
+                          self.router._get_drivers_for_message(
+-                             group, "foo.1", None))
++                             group, "foo.1", "info"))
+ 
+         # Foo itself ...
+         self.assertEqual([],
+                          self.router._get_drivers_for_message(
+-                             group, "foo", None))
++                             group, "foo", "info"))
+ 
+         # Child of blah.zoo
+         self.assertEqual(['rpc'],
+                          self.router._get_drivers_for_message(
+-                             group, "blah.zoo.zing", None))
++                             group, "blah.zoo.zing", "info"))
+ 
+     def test_get_drivers_for_message_accepted_priorities(self):
+         config = r"""
+@@ -461,21 +466,58 @@ group_1:
+         ext.name = "rpc"
+ 
+         # Good ...
+-        self.assertTrue(self.router._filter_func(ext, {}, {},
++        self.assertTrue(self.router._filter_func(ext, {}, {}, 'info',
+                         ['foo', 'rpc']))
+ 
+         # Bad
+-        self.assertFalse(self.router._filter_func(ext, {}, {}, ['foo']))
++        self.assertFalse(self.router._filter_func(ext, {}, {}, 'info',
++                                                  ['foo']))
+ 
+     def test_notify(self):
+         self.router.routing_groups = {'group_1': None, 'group_2': None}
+-        message = {'event_type': 'my_event', 'priority': 'my_priority'}
+-
+         drivers_mock = mock.MagicMock()
+         drivers_mock.side_effect = [['rpc'], ['foo']]
+ 
+         with mock.patch.object(self.router, 'plugin_manager') as pm:
+             with mock.patch.object(self.router, '_get_drivers_for_message',
+                                    drivers_mock):
+-                self.router.notify({}, message)
+-                self.assertEqual(pm.map.call_args[0][4], ['rpc', 'foo'])
++                self.notifier.info({}, 'my_event', {})
++                self.assertEqual(pm.map.call_args[0][5], ['rpc', 'foo'])
++
++    def test_notify_filtered(self):
++        self.config(routing_notifier_config="routing_notifier.yaml")
++        routing_config = r"""
++group_1:
++    rpc:
++        accepted_events:
++          - my_event
++    rpc2:
++        accepted_priorities:
++          - info
++    bar:
++        accepted_events:
++            - nothing
++        """
++        config_file = mock.MagicMock()
++        config_file.return_value = routing_config
++
++        rpc_driver = mock.Mock()
++        rpc2_driver = mock.Mock()
++        bar_driver = mock.Mock()
++
++        pm = dispatch.DispatchExtensionManager.make_test_instance(
++            [extension.Extension('rpc', None, None, rpc_driver),
++             extension.Extension('rpc2', None, None, rpc2_driver),
++             extension.Extension('bar', None, None, bar_driver)],
++        )
++
++        with contextlib.nested(
++            mock.patch.object(self.router, '_get_notifier_config_file',
++                              config_file),
++            mock.patch('stevedore.dispatch.DispatchExtensionManager',
++                       return_value=pm)):
++                self.notifier.info({}, 'my_event', {})
++                self.assertFalse(bar_driver.info.called)
++                rpc_driver.notify.assert_called_once_with({}, mock.ANY, 'INFO')
++                rpc2_driver.notify.assert_called_once_with(
++                    {}, mock.ANY, 'INFO')
diff --git a/python-oslo-messaging.spec b/python-oslo-messaging.spec
index 6df2fb2..347f821 100644
--- a/python-oslo-messaging.spec
+++ b/python-oslo-messaging.spec
@@ -10,6 +10,9 @@ License:    ASL 2.0
 URL:        https://launchpad.net/oslo
 Source0:    http://tarballs.openstack.org/oslo.messaging/%{sname}-%{version}.tar.gz
 
+Patch0001: 0001-Add-check-credentials-to-log-message-if-rabbmitmq-cl.patch
+Patch0002: 0002-Fix-the-notify-method-of-the-routing-notifier.patch
+
 BuildArch:  noarch
 Requires:   python-setuptools
 Requires:   python-iso8601
@@ -55,6 +58,9 @@ Documentation for the oslo.messaging library.
 %prep
 %setup -q -n %{sname}-%{version}
 
+%patch0001 -p1
+%patch0002 -p1
+
 # Remove bundled egg-info
 rm -rf %{sname}.egg-info
 # let RPM handle deps


More information about the scm-commits mailing list