Merge "share recycle bin, Fix follow-up suggestions"
This commit is contained in:
commit
7269f2a9e4
@ -323,6 +323,8 @@ Response parameters
|
||||
- volume_type: volume_type_shares_response
|
||||
- export_location: export_location
|
||||
- export_locations: export_locations
|
||||
- is_soft_deleted: is_soft_deleted_response
|
||||
- scheduled_to_be_deleted_at: scheduled_to_be_deleted_at_response
|
||||
|
||||
Response example
|
||||
----------------
|
||||
@ -487,6 +489,8 @@ Response parameters
|
||||
- volume_type: volume_type_shares_response
|
||||
- export_location: export_location
|
||||
- export_locations: export_locations
|
||||
- is_soft_deleted: is_soft_deleted_response
|
||||
- scheduled_to_be_deleted_at: scheduled_to_be_deleted_at_response
|
||||
|
||||
Response example
|
||||
----------------
|
||||
@ -592,6 +596,8 @@ Response parameters
|
||||
- volume_type: volume_type_shares_response
|
||||
- export_location: export_location
|
||||
- export_locations: export_locations
|
||||
- is_soft_deleted: is_soft_deleted_response
|
||||
- scheduled_to_be_deleted_at: scheduled_to_be_deleted_at_response
|
||||
|
||||
Response example
|
||||
----------------
|
||||
@ -690,6 +696,8 @@ Response parameters
|
||||
- volume_type: volume_type_shares_response
|
||||
- export_location: export_location
|
||||
- export_locations: export_locations
|
||||
- is_soft_deleted: is_soft_deleted_response
|
||||
- scheduled_to_be_deleted_at: scheduled_to_be_deleted_at_response
|
||||
|
||||
Response example
|
||||
----------------
|
||||
|
@ -308,8 +308,8 @@ class ShareController(wsgi.Controller,
|
||||
# it too late to restore the share.
|
||||
if share['status'] in [constants.STATUS_DELETING,
|
||||
constants.STATUS_ERROR_DELETING]:
|
||||
msg = _("Share %s is being deleted or error deleted, "
|
||||
"cannot be restore.")
|
||||
msg = _("Share %s is being deleted or has suffered an error "
|
||||
"during deletion, cannot be restored.")
|
||||
raise exc.HTTPForbidden(explanation=msg % id)
|
||||
|
||||
self.share_api.restore(context, share)
|
||||
|
@ -3514,8 +3514,16 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
expired_shares = self.db.get_all_expired_shares(ctxt)
|
||||
|
||||
for share in expired_shares:
|
||||
LOG.debug("share %s has expired, will be deleted", share['id'])
|
||||
self.share_api.delete(ctxt, share, force=True)
|
||||
if share['status'] == constants.STATUS_ERROR_DELETING:
|
||||
LOG.info("Share %s was soft-deleted but a prior deletion "
|
||||
"attempt failed. Resetting status and re-attempting "
|
||||
"deletion", share['id'])
|
||||
# reset share status to error in order to try deleting again
|
||||
update_data = {'status': constants.STATUS_ERROR}
|
||||
self.db.share_update(ctxt, share['id'], update_data)
|
||||
else:
|
||||
LOG.info("share %s has expired, will be deleted", share['id'])
|
||||
self.share_api.delete(ctxt, share)
|
||||
|
||||
@add_hooks
|
||||
@utils.require_driver_initialized
|
||||
|
@ -3976,17 +3976,21 @@ class ShareManagerTestCase(test.TestCase):
|
||||
'server1')
|
||||
timeutils.utcnow.assert_called_once_with()
|
||||
|
||||
@mock.patch.object(db, 'get_all_expired_shares',
|
||||
mock.Mock(return_value=[{"id": "share1"}, ]))
|
||||
@mock.patch.object(api.API, 'delete',
|
||||
mock.Mock())
|
||||
def test_delete_expired_share(self):
|
||||
@ddt.data("available", "error_deleting")
|
||||
def test_delete_expired_share(self, share_status):
|
||||
self.mock_object(db, 'get_all_expired_shares',
|
||||
mock.Mock(return_value=[{"id": "share1",
|
||||
"status": share_status}, ]))
|
||||
self.mock_object(db, 'share_update')
|
||||
self.mock_object(api.API, 'delete')
|
||||
self.share_manager.delete_expired_share(self.context)
|
||||
db.get_all_expired_shares.assert_called_once_with(
|
||||
self.context)
|
||||
share1 = {"id": "share1"}
|
||||
db.get_all_expired_shares.assert_called_once_with(self.context)
|
||||
share1 = {"id": "share1", "status": share_status}
|
||||
if share1["status"] == "error_deleting":
|
||||
db.share_update.assert_called_once_with(
|
||||
self.context, share1["id"], {'status': 'error'})
|
||||
api.API.delete.assert_called_once_with(
|
||||
self.context, share1, force=True)
|
||||
self.context, share1)
|
||||
|
||||
@mock.patch('manila.tests.fake_notifier.FakeNotifier._notify')
|
||||
def test_extend_share_invalid(self, mock_notify):
|
||||
|
Loading…
Reference in New Issue
Block a user