Vm reboot to Error state cause delete dangling bdms
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Fix Released
|
Undecided
|
Amit Uniyal |
Bug Description
Hi Community,
I've got the error with this patch when rebooting vm with volume source from the image, the result is Error with VolumeDeviceNot
Environment:
OpenStack Bobcat Stable version
Cinder driver: Tested with both Netapp & Powerstore iSCSI driver
Reproduce:
- Create VM from image (volume source type image, des type volume)
- Hard reboot or soft reboot
- VM damage with state Error, the volume attachment from cinder.
- The LUN mapping has been remove from the SAN storage (cause of volume_attachment record is deleted)
Workaround:
- Recover the attachment record by setting the column deleted to 0
- Manually set the LUN mapping on SAN storage to the corresponding LUN id from attachment record
- Hard reboot and VM running
Reference;
[1] https:/
for bdm in bdms.objects:
if bdm.volume_id and bdm.source_type == 'volume' and \ ==> This line lead to bug
Changed in nova: | |
status: | Triaged → In Progress |
Changed in nova: | |
assignee: | nobody → Amit Uniyal (auniyal) |
Hello Sang,
Thanks for reporting this bug, can check if my below assumption is the correct one:
# attachments present in nova DB, ones nova knows about
nova_attachmen ts = []
bdms_to_ delete = []
bdm.destinati on_type == 'volume':
try:
self. volume_ api.attachment_ get(context, bdm.attachment_id)
except exception. VolumeAttachmen tNotFound:
LOG. info(
f"Removing stale volume attachment "
f"'{ bdm.attachment_ id}' from instance for "
f"volume '{bdm.volume_ id}'.", instance=instance)
bdm. destroy( )
bdms_ to_delete. append( bdm)
else:
nova_ attachments. append( bdm.attachment_ id) <---- we don't pass here
for bdm in bdms.objects:
if bdm.volume_id and bdm.source_type == 'volume' and \ <--- if bdm.source_type == image
if len(set( cinder_ attachments) - set(nova_ attachments) ): <--- so nova_attachements empty
LOG. info(
"Removing stale volume attachments of instance from "
"Cinder" , instance=instance) attachments) - set(nova_ attachments) :
LOG. debug(
f"Removing attachment '{each_attach}'", instance=instance)
self. volume_ api.attachment_ delete( context, each_attach) <--- we delete the cinder attachment!
for each_attach in set(cinder_
# delete only cinder known attachments, from cinder DB.
# refresh bdms object
bdms. objects. remove( bdm)
for bdm in bdms_to_delete:
Can you check you have "Removing attachment...." in your logs (need to be in debug mode).
So we need to fix:
bdm.destinati on_type == 'volume':
if bdm.volume_id and bdm.source_type == 'volume' and \
to
bdm.destinati on_type == 'volume':
if bdm.volume_id and (bdm.source_type == 'volume' or bdm.source_type == 'image') and \
or maybe removing the bdm.source_type check ?