Comment 0 for bug 1381106

Revision history for this message
Mitsuhiro Tanino (mitsuhiro-tanino) wrote : Unexpected cinder volumes export occur after restarting cinder-volume

When I restarted cinder-volume service, I noticed that all cinder volumes which use LVMISCSIDriver are exported via tgtd unexpectedly.
If the volumes are attached to nova instances, they shoukd be exported via tgtd after restarting cinder-volume.
But the volumes which are not attached to instances must not be exported because everyone can connect these volumes.

Here is my cinder.conf and some logs.
  http://paste.openstack.org/show/121028/

I think this is a patch of the root cause for this problem.
Originally, ensure_export() was only called if the volume status was 'in-use'.
This means that if a volume was attached to an instance, the volume was exported after restarting cinder-volume service.

However, after applying this patch, ensure_export() is called if the volume is 'available' status.
Despite the volume is not attached to specific instance but the volume is exported to outside.
This is wrong behaviour.

In my understainding. ensure_export() must be called only the volume status is 'in-use'.

Commit
=========================================
commit ffefe18334a9456250e1b6ff88b7b47fb366f374
Author: Zhiteng Huang <email address hidden>
Date: Sat Aug 23 18:32:57 2014 +0000

-------
             for volume in volumes:
- if volume['status'] in ['in-use']:
+ # available volume should also be counted into allocated
+ if volume['status'] in ['in-use', 'available']:
                     # calculate allocated capacity for driver
- sum += volume['size']
- self.stats['allocated_capacity_gb'] = sum
+ self._count_allocated_capacity(ctxt, volume)
+
                     try:
                         self.driver.ensure_export(ctxt, volume)
                     except Exception as export_ex:
-------