Add debug logging around multiattach status changes

When deleting an attachment, we now need to check for any other
attachments for the volume and try to set the status correctly
based on any of those remaining attachments.

There's not very much logging around this to help us out if
something goes wrong, so this patch just proposes some debug
level logging be added around the process.

Change-Id: I64b3046cfb3355b547e158783131338b8b0180d1
This commit is contained in:
John Griffith 2018-01-24 16:15:57 +00:00
parent 6bbab2ff57
commit f7b6a4acee

View File

@ -2167,12 +2167,21 @@ class API(base.Base):
status_updates = {'status': 'available',
'attach_status': 'detached'}
remaining_attachments = AO_LIST.get_all_by_volume_id(ctxt, volume.id)
LOG.debug("Remaining volume attachments: %s", remaining_attachments,
resource=volume)
# NOTE(jdg) Try and figure out the > state we have left and set that
# attached > attaching > > detaching > reserved
pending_status_list = []
for attachment in remaining_attachments:
pending_status_list.append(attachment.attach_status)
LOG.debug("Adding status of: %s to pending status list "
"for volume.", attachment.attach_status,
resource=volume)
LOG.debug("Pending status list for volume during "
"attachment-delete: %s",
pending_status_list, resource=volume)
if 'attached' in pending_status_list:
status_updates['status'] = 'in-use'
status_updates['attach_status'] = 'attached'