From c296105692c932659be56f7d1c9b18703c127429 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 3 Mar 2021 12:08:01 +0100 Subject: [PATCH] Remove unnecessary DB read Attachment OVO automatically loads the Volume OVO into its `volume` attribute, so we don't need to load it again in the volume's API `attachment_delete` method. Change-Id: I79f2e58de42fca69c08f3636d72b80bdf8457e9a --- cinder/volume/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 215bfe88b1c..58832a4fe95 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -2263,7 +2263,7 @@ class API(base.Base): def attachment_delete(self, ctxt, attachment): ctxt.authorize(attachment_policy.DELETE_POLICY, target_obj=attachment) - volume = objects.Volume.get_by_id(ctxt, attachment.volume_id) + volume = attachment.volume if attachment.attach_status == fields.VolumeAttachStatus.RESERVED: self.db.volume_detached(ctxt.elevated(), attachment.volume_id, attachment.get('id'))