Merge "Remove unnecessary DB read"

This commit is contained in:
Zuul 2021-04-28 21:28:40 +00:00 committed by Gerrit Code Review
commit 7441694cd4
1 changed files with 1 additions and 1 deletions

View File

@ -2255,7 +2255,7 @@ class API(base.Base):
def attachment_delete(self, ctxt, attachment): def attachment_delete(self, ctxt, attachment):
ctxt.authorize(attachment_policy.DELETE_POLICY, ctxt.authorize(attachment_policy.DELETE_POLICY,
target_obj=attachment) target_obj=attachment)
volume = objects.Volume.get_by_id(ctxt, attachment.volume_id) volume = attachment.volume
if attachment.attach_status == fields.VolumeAttachStatus.RESERVED: if attachment.attach_status == fields.VolumeAttachStatus.RESERVED:
self.db.volume_detached(ctxt.elevated(), attachment.volume_id, self.db.volume_detached(ctxt.elevated(), attachment.volume_id,
attachment.get('id')) attachment.get('id'))