From baefbcd0a9c086bd0a019bdfdfa2dc7bcb60534c Mon Sep 17 00:00:00 2001 From: haixin Date: Wed, 30 Oct 2019 16:51:30 +0800 Subject: [PATCH] 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 be149c4c6bf354048bfb9f31d27c4a1b64de3fe1) (cherry picked from commit badb396732f4744159be24ece2799fb1377d07d8) --- manila/message/message_field.py | 13 +++++++++++-- manila/share/manager.py | 8 +++++++- ...or-when-share-extend-error-a0c458204b395994.yaml | 5 +++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1850264-add-async-error-when-share-extend-error-a0c458204b395994.yaml diff --git a/manila/message/message_field.py b/manila/message/message_field.py index c242bacaba..de51b5d0f5 100644 --- a/manila/message/message_field.py +++ b/manila/message/message_field.py @@ -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 = { diff --git a/manila/share/manager.py b/manila/share/manager.py index 75a00144fc..11b6de7c76 100644 --- a/manila/share/manager.py +++ b/manila/share/manager.py @@ -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'], diff --git a/releasenotes/notes/bug-1850264-add-async-error-when-share-extend-error-a0c458204b395994.yaml b/releasenotes/notes/bug-1850264-add-async-error-when-share-extend-error-a0c458204b395994.yaml new file mode 100644 index 0000000000..269eadcbcf --- /dev/null +++ b/releasenotes/notes/bug-1850264-add-async-error-when-share-extend-error-a0c458204b395994.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + A new user message has been added in case of share extensions failing + asynchronously. \ No newline at end of file