Add asynchronous error info into messages when share extend error

The database table messages is used to record various asynchronous error
messages, extend share is an asynchronously invoked procedure, when the
driver layer fails to execute extend share, we should record this
asynchronous error into database. This commit modify this behavior, and
now this asynchronows error is recorded in the database.

Closes-Bug:#1850264
Change-Id: I06a9bf24ab3d4aa5f4f5446d344bf55d71803e47
(cherry picked from commit be149c4c6b)
(cherry picked from commit badb396732)
This commit is contained in:
haixin 2019-10-30 16:51:30 +08:00 committed by Goutham Pacha Ravi
parent f641ea82d8
commit baefbcd0a9
3 changed files with 23 additions and 3 deletions

View File

@ -31,13 +31,15 @@ class Action(object):
UPDATE = ('005', _('update'))
REVERT_TO_SNAPSHOT = ('006', _('revert to snapshot'))
DELETE = ('007', _('delete'))
EXTEND = ('008', _('extend'))
ALL = (ALLOCATE_HOST,
CREATE,
DELETE_ACCESS_RULES,
PROMOTE,
UPDATE,
REVERT_TO_SNAPSHOT,
DELETE)
DELETE,
EXTEND)
class Detail(object):
@ -72,6 +74,12 @@ class Detail(object):
FILTER_JSON = ('012', FILTER_MSG % 'Json')
FILTER_RETRY = ('013', FILTER_MSG % 'Retry')
FILTER_REPLICATION = ('014', FILTER_MSG % 'ShareReplication')
DRIVER_FAILED_EXTEND = (
'015',
_("Share Driver failed to extend share, The share status has been "
"set to extending_error. This action cannot be re-attempted until "
"the status has been rectified. Contact your administrator to "
"determine the cause of this failure."))
ALL = (UNKNOWN_ERROR,
NO_VALID_HOST,
@ -86,7 +94,8 @@ class Detail(object):
FILTER_IGNORE,
FILTER_JSON,
FILTER_RETRY,
FILTER_REPLICATION)
FILTER_REPLICATION,
DRIVER_FAILED_EXTEND)
# Exception and detail mappings
EXCEPTION_DETAIL_MAPPINGS = {

View File

@ -3800,7 +3800,13 @@ class ShareManager(manager.SchedulerDependentManager):
share_instance, new_size, share_server=share_server)
except Exception as e:
LOG.exception("Extend share failed.", resource=share)
self.message_api.create(
context,
message_field.Action.EXTEND,
project_id,
resource_type=message_field.Resource.SHARE,
resource_id=share_id,
detail=message_field.Detail.DRIVER_FAILED_EXTEND)
try:
self.db.share_update(
context, share['id'],

View File

@ -0,0 +1,5 @@
---
fixes:
- |
A new user message has been added in case of share extensions failing
asynchronously.