Fix attachment_delete for reserved case
In attachment-delete we attempt a little short cut in cases where the volume is reserved but not actually attached to an instance. In this case we don't have a connector and we never actually sent anything to the driver, so we take a short cut in cinder.volume.api and we just call an object.destroy(). The problem with this is that the object doesn't do the proper/needed context settings and checks and just fails due to policy. We should clean this up and add the extra db update steps and also include the notification messages. Change-Id: Ib448f0548739cd42edf03eab07f305b3ac184d8f Closes-Bug: #1702512
This commit is contained in:
parent
640b870f9c
commit
80b943c7f2
@ -2003,7 +2003,12 @@ class API(base.Base):
|
||||
def attachment_delete(self, ctxt, attachment):
|
||||
volume = objects.Volume.get_by_id(ctxt, attachment.volume_id)
|
||||
if attachment.attach_status == 'reserved':
|
||||
attachment.destroy()
|
||||
self.db.volume_detached(ctxt.elevated(), attachment.volume_id,
|
||||
attachment.get('id'))
|
||||
self.db.volume_admin_metadata_delete(ctxt.elevated(),
|
||||
attachment.volume_id,
|
||||
'attached_mode')
|
||||
volume_utils.notify_about_volume_usage(ctxt, volume, "detach.end")
|
||||
else:
|
||||
self.volume_rpcapi.attachment_delete(ctxt,
|
||||
attachment.id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user