Merge "Fix backup-import error when the deleted record in the same db"

This commit is contained in:
Zuul 2017-10-19 10:00:38 +00:00 committed by Gerrit Code Review
commit 5581052415
2 changed files with 9 additions and 5 deletions

View File

@ -490,16 +490,18 @@ class API(base.Base):
'project_id': context.project_id,
'volume_id': IMPORT_VOLUME_ID,
'status': fields.BackupStatus.CREATING,
'deleted_at': None,
'deleted': False,
'metadata': {}
}
try:
# Try to get the backup with that ID in all projects even among
# deleted entries.
backup = objects.BackupImport.get_by_id(context,
backup_record['id'],
read_deleted='yes',
project_only=False)
backup = objects.BackupImport.get_by_id(
context.elevated(read_deleted='yes'),
backup_record['id'],
project_only=False)
# If record exists and it's not deleted we cannot proceed with the
# import

View File

@ -6784,8 +6784,10 @@ def worker_destroy(context, **filters):
@require_context
def resource_exists(context, model, resource_id, session=None):
conditions = [model.id == resource_id]
# Match non deleted resources by the id
conditions = [model.id == resource_id, ~model.deleted]
if 'no' == context.read_deleted:
conditions.append(~model.deleted)
# If the context is not admin we limit it to the context's project
if is_user_context(context) and hasattr(model, 'project_id'):
conditions.append(model.project_id == context.project_id)