Comment 0 for bug 1579667

Revision history for this message
Peter Wang (peter.wang) wrote :

When deleting an shelved_offloaded STATE VM instance with volume attached, nova passes a connector dictionary:

  connector = {'ip': '127.0.0.1', 'initiator': 'iqn.fake'}

to cinder for terminate connnection, this causes KeyError in cinder driver
code :
https://github.com/openstack/nova/blame/master/nova/compute/api.py#L1803

    def _local_cleanup_bdm_volumes(self, bdms, instance, context):
1804 """The method deletes the bdm records and, if a bdm is a volume, call
1805 the terminate connection and the detach volume via the Volume API.
1806 Note that at this point we do not have the information about the
1807 correct connector so we pass a fake one.
1808 """
1809 elevated = context.elevated()
1810 for bdm in bdms:
1811 if bdm.is_volume:
1812 # NOTE(vish): We don't have access to correct volume
1813 # connector info, so just pass a fake
1814 # connector. This can be improved when we
1815 # expose get_volume_connector to rpc.
1816 connector = {'ip': '127.0.0.1', 'initiator': 'iqn.fake'}
1817 try:
1818 self.volume_api.terminate_connection(context,
1819 bdm.volume_id,
1820 connector)
1821 self.volume_api.detach(elevated, bdm.volume_id,
1822 instance.uuid)
1823 if bdm.delete_on_termination:
1824 self.volume_api.delete(context, bdm.volume_id)
1825 except Exception as exc:
1826 err_str = _LW("Ignoring volume cleanup failure due to %s")
1827 LOG.warn(err_str % exc, instance=instance)
1828 bdm.destroy()
1829
https://github.com/openstack/nova/blame/master/nova/compute/api.py#L1828

according to my debug, the connector info for terminate_connection is already there( in bdm object):

so Nova should build correct connection info for terminate_connection.

Thanks
Peter