From 4bac18b28c5ada7735b87caebd9f4ee86edc9c65 Mon Sep 17 00:00:00 2001 From: Maciej Szankin Date: Tue, 15 Nov 2016 10:40:54 -0600 Subject: [PATCH] conf: remove deprecated exception option Change-Id: Ia27d4040f317e5e70ac53341eccc80c868fe99e5 Implements: blueprint centralize-config-options-ocata --- nova/conf/__init__.py | 2 - nova/conf/exceptions.py | 40 ------------------- nova/exception.py | 9 +---- nova/tests/unit/conf_fixture.py | 1 - nova/tests/unit/test_exception.py | 2 - ...d_exception_conf_opt-94bfea599c2ebf5c.yaml | 5 +++ 6 files changed, 6 insertions(+), 53 deletions(-) delete mode 100644 nova/conf/exceptions.py create mode 100644 releasenotes/notes/remove_deprecated_exception_conf_opt-94bfea599c2ebf5c.yaml diff --git a/nova/conf/__init__.py b/nova/conf/__init__.py index 82519b9ee4..e5337284b2 100644 --- a/nova/conf/__init__.py +++ b/nova/conf/__init__.py @@ -35,7 +35,6 @@ from nova.conf import consoleauth from nova.conf import crypto from nova.conf import database from nova.conf import ephemeral_storage -from nova.conf import exceptions from nova.conf import flavors from nova.conf import floating_ips from nova.conf import glance @@ -92,7 +91,6 @@ consoleauth.register_opts(CONF) crypto.register_opts(CONF) database.register_opts(CONF) ephemeral_storage.register_opts(CONF) -exceptions.register_opts(CONF) floating_ips.register_opts(CONF) flavors.register_opts(CONF) glance.register_opts(CONF) diff --git a/nova/conf/exceptions.py b/nova/conf/exceptions.py deleted file mode 100644 index a5384a247d..0000000000 --- a/nova/conf/exceptions.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2016 OpenStack Foundation -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslo_config import cfg - -exc_log_opts = [ - cfg.BoolOpt('fatal_exception_format_errors', - default=False, - deprecated_for_removal=True, - deprecated_since="14.0.0", - deprecated_reason="This is only used for internal testing.", - help=""" -When set to true, this option enables validation of exception -message format. - -This option is used to detect errors in NovaException class when it formats -error messages. If True, raise an exception; if False, use the unformatted -message. -""") -] - - -def register_opts(conf): - conf.register_opts(exc_log_opts) - - -def list_opts(): - return {'DEFAULT': exc_log_opts} diff --git a/nova/exception.py b/nova/exception.py index d50b259a11..e28ee98fd4 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -22,8 +22,6 @@ SHOULD include dedicated exception logging. """ -import sys - from oslo_log import log as logging import six import webob.exc @@ -88,18 +86,13 @@ class NovaException(Exception): message = self.msg_fmt % kwargs except Exception: - exc_info = sys.exc_info() # kwargs doesn't match a variable in the message # log the issue and the kwargs LOG.exception(_LE('Exception in string format operation')) for name, value in six.iteritems(kwargs): LOG.error("%s: %s" % (name, value)) # noqa - if CONF.fatal_exception_format_errors: - six.reraise(*exc_info) - else: - # at least get the core message out if something happened - message = self.msg_fmt + message = self.msg_fmt self.message = message super(NovaException, self).__init__(message) diff --git a/nova/tests/unit/conf_fixture.py b/nova/tests/unit/conf_fixture.py index 981f137053..5b6269aa0a 100644 --- a/nova/tests/unit/conf_fixture.py +++ b/nova/tests/unit/conf_fixture.py @@ -54,7 +54,6 @@ class ConfFixture(config_fixture.Config): self.conf.set_default('sqlite_synchronous', False, group='database') self.conf.set_default('sqlite_synchronous', False, group='api_database') - self.conf.set_default('fatal_exception_format_errors', True) # TODO(sdague): this makes our project_id match 'fake' as well. # We should fix the tests to use real # UUIDs then drop this work around. diff --git a/nova/tests/unit/test_exception.py b/nova/tests/unit/test_exception.py index b4ff568e15..07f99ed1d7 100644 --- a/nova/tests/unit/test_exception.py +++ b/nova/tests/unit/test_exception.py @@ -188,7 +188,6 @@ class NovaExceptionTestCase(test.NoDBTestCase): def __unicode__(self): return u"print the whole trace" - self.flags(fatal_exception_format_errors=False) exc = FakeNovaException_Remote(lame_arg='lame') self.assertEqual("some message %(somearg)s", exc.format_message()) @@ -219,7 +218,6 @@ class ExceptionTestCase(test.NoDBTestCase): def test_exceptions_raise(self): # NOTE(dprince): disable format errors since we are not passing kwargs - self.flags(fatal_exception_format_errors=False) for name in dir(exception): exc = getattr(exception, name) if isinstance(exc, type): diff --git a/releasenotes/notes/remove_deprecated_exception_conf_opt-94bfea599c2ebf5c.yaml b/releasenotes/notes/remove_deprecated_exception_conf_opt-94bfea599c2ebf5c.yaml new file mode 100644 index 0000000000..b91521ead1 --- /dev/null +++ b/releasenotes/notes/remove_deprecated_exception_conf_opt-94bfea599c2ebf5c.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + ``fatal_exception_format_errors`` configuration option has been removed, + as it was only used for internal testing. \ No newline at end of file -- 2.39.5