]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stop logging unnecessary warning on context create
authorMaru Newby <marun@redhat.com>
Wed, 27 Nov 2013 07:57:48 +0000 (07:57 +0000)
committerMaru Newby <marun@redhat.com>
Thu, 28 Nov 2013 09:17:18 +0000 (09:17 +0000)
The context was previously logging at the 'warn' level when unknown
kwargs were being passed to its __init__().  Since the agents were
passing tenant=None with each rpc request, this was generating an
unreasonable amount of log chatter that would not be useful to an
operator.  The fix is to log at the debug level instead so that
the operators don't see the output by default but developers can
still choose to.

Change-Id: I5c328f628c597eb949c1fe67b23120d2b5d1c7da
Related-Bug: #1254530
Partial-Bug: #1255441

neutron/context.py
neutron/tests/unit/test_neutron_context.py

index 1dadd4c4b038fb995e6ed92eaed2249e8a0034bf..af2469663160b025e8aa716d4535a32f8808aa8f 100644 (file)
@@ -80,8 +80,8 @@ class ContextBase(common_context.RequestContext):
         # Log only once the context has been configured to prevent
         # format errors.
         if kwargs:
-            LOG.warn(_('Arguments dropped when creating '
-                       'context: %s'), kwargs)
+            LOG.debug(_('Arguments dropped when creating '
+                        'context: %s'), kwargs)
 
     @property
     def project_id(self):
index a756e8f2bbfa688c3a2e5698a69d3aceb5d3de3d..5a36c850e0514ab355cd2c0cac39d286b1200a5a 100644 (file)
@@ -43,10 +43,10 @@ class TestNeutronContext(base.BaseTestCase):
         self.assertIsNone(ctx.user_name)
         self.assertIsNone(ctx.tenant_name)
 
-    def test_neutron_context_create_logs_unknown_kwargs(self):
-        with mock.patch.object(context.LOG, 'warn') as mock_warn:
-            context.Context('user_id', 'tenant_id', foo='bar')
-        self.assertEqual(mock_warn.call_count, 1)
+    def test_neutron_context_create_logs_unknown_kwarg(self):
+        with mock.patch.object(context.LOG, 'debug') as mock_log:
+            context.Context('user_id', 'tenant_id', foo=None)
+        self.assertEqual(mock_log.call_count, 1)
 
     def test_neutron_context_create_with_name(self):
         ctx = context.Context('user_id', 'tenant_id',