From dcd14adb61b018501f3c0525ecfd7c13535cf386 Mon Sep 17 00:00:00 2001 From: Jens Rosenboom Date: Tue, 19 Apr 2016 12:35:17 +0200 Subject: [PATCH] Avoid unconditional warnings in nova-consoleauth With the introduction of oslo_cache, there is no feedback anymore about whether set()ting a cache item was successful, so we stop generating warnings about this all the time. Change-Id: I2ca0cdd3dd30498a23da2ef4f352afd199496862 Partial-Bug: 1572062 --- nova/consoleauth/manager.py | 16 ++++------------ nova/tests/unit/consoleauth/test_consoleauth.py | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/nova/consoleauth/manager.py b/nova/consoleauth/manager.py index e34d396af4e2..6dc99e4d3306 100644 --- a/nova/consoleauth/manager.py +++ b/nova/consoleauth/manager.py @@ -26,7 +26,7 @@ from nova import cache_utils from nova.cells import rpcapi as cells_rpcapi from nova.compute import rpcapi as compute_rpcapi import nova.conf -from nova.i18n import _LI, _LW +from nova.i18n import _LI from nova import manager from nova import objects @@ -88,12 +88,7 @@ class ConsoleAuthManager(manager.Manager): 'last_activity_at': time.time()} data = jsonutils.dumps(token_dict) - # We need to log the warning message if the token is not cached - # successfully, because the failure will cause the console for - # instance to not be usable. - if not self.mc.set(token.encode('UTF-8'), data): - LOG.warning(_LW("Token: %(token)s failed to save into memcached."), - {'token': token}) + self.mc.set(token.encode('UTF-8'), data) tokens = self._get_tokens_for_instance(instance_uuid) # Remove the expired tokens from cache. @@ -103,11 +98,8 @@ class ConsoleAuthManager(manager.Manager): if value is not None] tokens.append(token) - if not self.mc_instance.set(instance_uuid.encode('UTF-8'), - jsonutils.dumps(tokens)): - LOG.warning(_LW("Instance: %(instance_uuid)s failed to save " - "into memcached"), - {'instance_uuid': instance_uuid}) + self.mc_instance.set(instance_uuid.encode('UTF-8'), + jsonutils.dumps(tokens)) LOG.info(_LI("Received Token: %(token)s, %(token_dict)s"), {'token': token, 'token_dict': token_dict}) diff --git a/nova/tests/unit/consoleauth/test_consoleauth.py b/nova/tests/unit/consoleauth/test_consoleauth.py index d79444eb992f..2599a2ccfbda 100644 --- a/nova/tests/unit/consoleauth/test_consoleauth.py +++ b/nova/tests/unit/consoleauth/test_consoleauth.py @@ -152,11 +152,11 @@ class ControlauthMemcacheEncodingTestCase(test.NoDBTestCase): def test_authorize_console_encoding(self): with test.nested( mock.patch.object(self.manager.mc_instance, - 'set', return_value=True), + 'set', return_value=None), mock.patch.object(self.manager.mc_instance, 'get', return_value='["token"]'), mock.patch.object(self.manager.mc, - 'set', return_value=True), + 'set', return_value=None), mock.patch.object(self.manager.mc, 'get', return_value=None), mock.patch.object(self.manager.mc,