Detach volume from instance
After instance deletion the used volume is still attached to that instance. As unfortunately the code flow is not obvious. Every comments helps to understand that Delete partition flow: driver.destroy driver.get_volume_connector see line 2244 and 2268 https://github.com/openstack/nova/blob/master/nova/compute/manager.py#L2244-L2268 Problem: Once partition deleted we can not get hbas wwpns. so driver.get_volume_connector will not return wwpns. 'wwpns' and 'host' is required for cinder to detach the volume from instance. (Both 'wwpns' and 'host' are used to attach and detach the volume from instance) Solution: Before deleting partition we will save wwpns And once we will return driver.get_volume_connector then no need to save it because instance will be no more existing. closes-Bug: 1663323 Change-Id: If58a4a693841fe32375e987b56f9ca54033dd6ef Signed-off-by: Prabhat Ranjan <pranjank@in.ibm.com>
This commit is contained in:
parent
5437a44e8a
commit
c7a2f6f93a
|
@ -69,6 +69,8 @@ class DPMDriver(driver.ComputeDriver):
|
|||
self._fc_wwnns = None
|
||||
self._fc_wwpns = None
|
||||
|
||||
self.deleted_instance_wwpns_mapping = {}
|
||||
|
||||
self.volume_drivers = self._get_volume_drivers()
|
||||
|
||||
def init_host(self, host):
|
||||
|
@ -184,9 +186,31 @@ class DPMDriver(driver.ComputeDriver):
|
|||
representing the Instance and discovers the instances LUNs
|
||||
to see which storage paths are active.
|
||||
"""
|
||||
inst = vm.PartitionInstance(instance, self._cpc)
|
||||
props = {}
|
||||
props['wwpns'] = inst.get_partition_wwpns()
|
||||
# 'get_volume_connector' will be invoked during creation
|
||||
# of the partition and during deletion of the partition.
|
||||
# But 'wwpns' we can access only when partition is available.
|
||||
# During spawn flow 'get_volume_connector' function will be called
|
||||
# before 'spawn' function so to get 'wwpns' we first creating
|
||||
# the partition using 'prep_for_spawn' function so that
|
||||
# we can access 'wwpns'.(i.e - else part)
|
||||
# But during deletion 'get_volume_connector' will be called
|
||||
# after 'destroy' function which will delete the partition so
|
||||
# after that we can not get the 'wwpns'
|
||||
# In order to get 'wwpns' after 'destroy' function we are
|
||||
# saving 'wwpns' before deleting partition in 'destroy' function
|
||||
# in 'deleted_instance_wwpns_mapping' variable and using these 'wwpns'
|
||||
# in 'get_volume_connector'(i.e - if part)
|
||||
# after using these 'wwpns' we are removing these 'wwpns' from
|
||||
# 'deleted_instance_wwpns_mapping' variable because
|
||||
# we are not going to use these 'wwpns' any more after this.
|
||||
if instance.uuid in self.deleted_instance_wwpns_mapping:
|
||||
props['wwpns'] = self.deleted_instance_wwpns_mapping.pop(
|
||||
instance.uuid)
|
||||
else:
|
||||
inst = vm.PartitionInstance(instance, self._cpc)
|
||||
props['wwpns'] = inst.get_partition_wwpns()
|
||||
|
||||
props['host'] = instance.uuid
|
||||
|
||||
return props
|
||||
|
@ -409,6 +433,11 @@ class DPMDriver(driver.ComputeDriver):
|
|||
def destroy(self, context, instance, network_info, block_device_info=None,
|
||||
destroy_disks=True, migrate_data=None):
|
||||
inst = vm.PartitionInstance(instance, self._cpc)
|
||||
# Need to save wwpns before deletion of the partition
|
||||
# Because after driver.destroy function driver.get_volume_connector
|
||||
# will be called which required hbas wwpns of partition.
|
||||
self.deleted_instance_wwpns_mapping[
|
||||
instance.uuid] = inst.get_partition_wwpns()
|
||||
inst.destroy()
|
||||
|
||||
def power_off(self, instance, timeout=0, retry_interval=0):
|
||||
|
|
Loading…
Reference in New Issue