From 655c4ce9e21642ed5801a7ac5996ca13d8fcc9ce Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 22 Jan 2018 19:32:54 -0600 Subject: [PATCH] Remove inner_exceptions plumbing We've finally gotten out of the business of wrapping exceptions. Since we don't do that anymore, we don't need the log_inner_exceptions logic. Change-Id: Id1f709daa2e61c13efeeeffc2a08578c27265e56 --- doc/source/user/logging.rst | 5 ----- shade/exc.py | 21 +++++---------------- shade/openstackcloud.py | 13 +------------ shade/tests/functional/base.py | 6 ++---- shade/tests/unit/base.py | 13 ++++--------- 5 files changed, 12 insertions(+), 46 deletions(-) diff --git a/doc/source/user/logging.rst b/doc/source/user/logging.rst index 5915de9ec..b4b5cc7d1 100644 --- a/doc/source/user/logging.rst +++ b/doc/source/user/logging.rst @@ -52,11 +52,6 @@ shade.request_ids This can be be useful for tracking action taken on the server-side if one does not want `HTTP Tracing`_. -shade.exc - If `log_inner_exceptions` is set to True, `shade` will emit any wrapped - exception to the `shade.exc` logger. Wrapped exceptions are usually - considered implementation details, but can be useful for debugging problems. - shade.iterate_timeout When `shade` needs to poll a resource, it does so in a loop that waits between iterations and ultimately timesout. The `shade.iterate_timeout` diff --git a/shade/exc.py b/shade/exc.py index c94489110..1ccc437de 100644 --- a/shade/exc.py +++ b/shade/exc.py @@ -32,26 +32,15 @@ class OpenStackCloudException(Exception): args.append("Extra: {0}".format(str(extra_data))) super(OpenStackCloudException, self).__init__(*args, **kwargs) self.extra_data = extra_data + # NOTE(mordred) The next two are not used for anything, but + # they are public attributes so we keep them around. self.inner_exception = sys.exc_info() self.orig_message = message def log_error(self, logger=None): - if not logger: - logger = _log.setup_logging('shade.exc') - if self.inner_exception and self.inner_exception[1]: - logger.error(self.orig_message, exc_info=self.inner_exception) - - def __str__(self): - message = Exception.__str__(self) - if (self.inner_exception and self.inner_exception[1] - and not self.orig_message.endswith( - str(self.inner_exception[1]))): - message = "%s (Inner Exception: %s)" % ( - message, - str(self.inner_exception[1])) - if self.log_inner_exceptions: - self.log_error() - return message + # NOTE(mordred) This method is here for backwards compat. As shade + # no longer wraps any exceptions, this doesn't do anything. + pass class OpenStackCloudCreateException(OpenStackCloudException): diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 2c41bdb18..e5d69c549 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -114,15 +114,7 @@ class OpenStackCloud( OpenStack API tasks. Unless you're doing rate limiting client side, you almost certainly don't need this. (optional) - :param bool log_inner_exceptions: Send wrapped exceptions to the error log. - Defaults to false, because there are a - number of wrapped exceptions that are - noise for normal usage. It's possible - that for a user that has python logging - configured properly, it's desirable to - have all of the wrapped exceptions be - emitted to the error log. This flag - will enable that behavior. + :param bool log_inner_exceptions: Ignored. Exists for backwards compat. :param bool strict: Only return documented attributes for each resource as per the shade Data Model contract. (Default False) :param app_name: Name of the application to be appended to the user-agent @@ -145,9 +137,6 @@ class OpenStackCloud( use_direct_get=False, **kwargs): - if log_inner_exceptions: - OpenStackCloudException.log_inner_exceptions = True - self.log = _log.setup_logging('shade') if not cloud_config: diff --git a/shade/tests/functional/base.py b/shade/tests/functional/base.py index f2fc32525..6e6ed159b 100644 --- a/shade/tests/functional/base.py +++ b/shade/tests/functional/base.py @@ -37,15 +37,13 @@ class BaseFunctionalTestCase(base.TestCase): user_config = self.config.get_one_cloud( cloud=self._demo_name, **kwargs) self.user_cloud = shade.OpenStackCloud( - cloud_config=user_config, - log_inner_exceptions=True) + cloud_config=user_config) def _set_operator_cloud(self, **kwargs): operator_config = self.config.get_one_cloud( cloud=self._op_name, **kwargs) self.operator_cloud = shade.OperatorCloud( - cloud_config=operator_config, - log_inner_exceptions=True) + cloud_config=operator_config) def pick_image(self): images = self.user_cloud.list_images() diff --git a/shade/tests/unit/base.py b/shade/tests/unit/base.py index b2a32e8ba..61a356661 100644 --- a/shade/tests/unit/base.py +++ b/shade/tests/unit/base.py @@ -126,15 +126,12 @@ class BaseTestCase(base.TestCase): self.cloud_config = self.config.get_one_cloud( cloud=test_cloud, validate=False) self.cloud = shade.OpenStackCloud( - cloud_config=self.cloud_config, - log_inner_exceptions=True) + cloud_config=self.cloud_config) self.strict_cloud = shade.OpenStackCloud( cloud_config=self.cloud_config, - log_inner_exceptions=True, strict=True) self.op_cloud = shade.OperatorCloud( - cloud_config=self.cloud_config, - log_inner_exceptions=True) + cloud_config=self.cloud_config) class TestCase(BaseTestCase): @@ -451,11 +448,9 @@ class RequestsMockTestCase(BaseTestCase): self.cloud_config = self.config.get_one_cloud( cloud=test_cloud, validate=True, **kwargs) self.cloud = shade.OpenStackCloud( - cloud_config=self.cloud_config, - log_inner_exceptions=True) + cloud_config=self.cloud_config) self.op_cloud = shade.OperatorCloud( - cloud_config=self.cloud_config, - log_inner_exceptions=True) + cloud_config=self.cloud_config) def get_glance_discovery_mock_dict( self,