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
This commit is contained in:
TommyLike 2018-06-06 13:36:12 +08:00
parent 9d263f711d
commit c25a1485f2
1 changed files with 5 additions and 0 deletions

View File

@ -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