Serialize message_* properties of RequestContext

Change Idc00b125b33b added the ability to store and retrieve user
message data in the request context, but it neglected to add code to
make sure they would persist across serialization and deserialization
of the request context object, as happens in the create-backup
workflow.  As a result, when a user message needed to be created to
describe an error condition in the backup driver, instead we'd get an
exception raised: "TypeError: 'NoneType' object is not subscriptable".

This patch fixes the issue by making sure the message_* properties
persist across serialization/deserialization of RequestContext objects.

Closes-Bug: 1978729
Change-Id: Ibdaaf39abafbae6bfcb9fdf9fb7a55d968ad9f11
Signed-off-by: Jesper Schmitz Mouridsen <jesper@schmitz.computer>
This commit is contained in:
Jesper Schmitz Mouridsen 2022-06-17 10:29:00 +00:00
parent 3e068b5ce0
commit c46d41719e
2 changed files with 20 additions and 3 deletions

View File

@ -91,6 +91,9 @@ class RequestContext(context.RequestContext):
quota_class=None,
service_catalog: Optional[dict] = None,
user_auth_plugin=None,
message_resource_id = None,
message_resource_type = None,
message_action = None,
**kwargs):
"""Initialize RequestContext.
@ -117,9 +120,9 @@ class RequestContext(context.RequestContext):
timestamp = timeutils.parse_isotime(timestamp)
self.timestamp = timestamp
self.quota_class = quota_class
self.message_resource_id = None
self.message_resource_type = None
self.message_action = None
self.message_resource_id = message_resource_id
self.message_resource_type = message_resource_type
self.message_action = message_action
if service_catalog:
# Only include required parts of service_catalog
@ -174,6 +177,9 @@ class RequestContext(context.RequestContext):
result['quota_class'] = self.quota_class
result['service_catalog'] = self.service_catalog
result['request_id'] = self.request_id
result['message_resource_id'] = self.message_resource_id
result['message_resource_type'] = self.message_resource_type
result['message_action'] = self.message_action
return result
@classmethod
@ -194,6 +200,9 @@ class RequestContext(context.RequestContext):
auth_token=values.get('auth_token'),
user_domain_id=values.get('user_domain_id'),
project_domain_id=values.get('project_domain_id'),
message_resource_id = values.get('message_resource_id'),
message_resource_type = values.get('message_resource_type'),
message_action = values.get('message_action')
)
def authorize(self,

View File

@ -0,0 +1,8 @@
---
fixes:
- |
`Bug #1978729 <https://bugs.launchpad.net/cinder/+bug/1978729>`_: Fixed
context.message_action is None on errors by backup drivers. The message_*
properties of the context were not passed during rpc, which caused a double
exception when a backup driver raised an exception, masking the actual backup
driver exception.