Fix six.reraise bug in rbac_rule_validation
This PS fixes an issue [0] when calling six.reraise in
rbac_rule_validation after a generic Exception has been
caught. Instead of using six.reraise and changing the
exception's detailed error message unnecessarily,
excutils.save_and_reraise_exception from oslo_utils
is used instead.
[0] http://logs.openstack.org/97/507697/5/check/legacy-tempest-dsvm-patrole-member/d2530aa/job-output.txt.gz#_2017-11-02_20_04_35_107548
Change-Id: I99f2cc60f301172847dd8f98fbc7deff4d5e94e4
diff --git a/patrole_tempest_plugin/rbac_rule_validation.py b/patrole_tempest_plugin/rbac_rule_validation.py
index 540d006..927c803 100644
--- a/patrole_tempest_plugin/rbac_rule_validation.py
+++ b/patrole_tempest_plugin/rbac_rule_validation.py
@@ -17,6 +17,7 @@
import sys
import testtools
+from oslo_utils import excutils
import six
from tempest import config
@@ -158,14 +159,14 @@
raise exceptions.Forbidden(
"%s Exception was: %s" % (msg, e))
except Exception as e:
- exc_info = sys.exc_info()
- error_details = exc_info[1].__str__()
- msg = ("An unexpected exception has occurred during test: %s. "
- "Exception was: %s"
- % (test_func.__name__, error_details))
- test_status = ('Error, %s' % (error_details))
- LOG.error(msg)
- six.reraise(exc_info[0], exc_info[0](msg), exc_info[2])
+ with excutils.save_and_reraise_exception():
+ exc_info = sys.exc_info()
+ error_details = six.text_type(exc_info[1])
+ msg = ("An unexpected exception has occurred during test: "
+ "%s. Exception was: %s" % (test_func.__name__,
+ error_details))
+ test_status = 'Error, %s' % (error_details)
+ LOG.error(msg)
else:
if not allowed:
LOG.error("Role %s was allowed to perform %s",