Comment 2 for bug 1681998

Revision history for this message
Hua Zhang (zhhuabj) wrote :

Hi Lee,

Thank you for your response. To illustrate my intentions to bypass the dirty BDM entry according to the condition that connection_info is NULL, I drafted a patch below just now:

diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index d6efd18..efbb225 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -4937,10 +4937,10 @@ class ComputeManager(manager.Manager):
                                                     wr_req, wr_bytes,
                                                     instance,
                                                     update_totals=True)
-
- self._driver_detach_volume(context, instance, bdm)
- connector = self.driver.get_volume_connector(instance)
- self.volume_api.terminate_connection(context, volume_id, connector)
+ if bdm.connection_info:
+ self._driver_detach_volume(context, instance, bdm)
+ connector = self.driver.get_volume_connector(instance)
+ self.volume_api.terminate_connection(context, volume_id, connector)

         if destroy_bdm:
             bdm.destroy()

When bdm.connection_info is NULL (means it's dirty data), we will bypass _driver_detach_volume() and terminate_connection() and just invoke bdm.destroy() to delete this dirty data. So:

1, If there are N (N > 1) BDMs with the same instance_uuid and volume_id, we can run 'nova detach' operation N times to delete N dirty BDMs.

2, Because above logic is just added in detach operation, so it will not affect all newly created BDMs would meet this criteria.

If you guys think I'm on the right road, I can spend time to test above patch and continue to submit the code review. Hope to hear from you. thanks.