From c25a1485f2976bec871e804cb5aacd3fe095b05e Mon Sep 17 00:00:00 2001 From: TommyLike Date: Wed, 6 Jun 2018 13:36:12 +0800 Subject: [PATCH] Remove kwargs 'message' when exception is created Now when rpc client rebuild exception at the middleware, the process will always fail because we have duplicate keyword 'message' there. Considering we already have a bunch of exceptions who need format key 'message' as below: ``` class VolumeDriverException(CinderException): message = _("Volume driver reported an error: %(message)s") ``` Instead of refactor all of them, this patch just removes the kwargs 'message' when exception is initialized. Closes-Bug: #1728826 Change-Id: I6bfa34a42df1f44e16b7536246def610821b7cba --- cinder/exception.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cinder/exception.py b/cinder/exception.py index fd2ef78b572..598f52297d1 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -111,6 +111,11 @@ class CinderException(Exception): # overshadowed by the class' message attribute self.msg = message super(CinderException, self).__init__(message) + # Oslo.messaging use the argument 'message' to rebuild exception + # directly at the rpc client side, therefore we should not use it + # in our keyword arguments, otherwise, the rebuild process will fail + # with duplicate keyword exception. + self.kwargs.pop('message', None) def _log_exception(self): # kwargs doesn't match a variable in the message