When cinder writes a qemu-based image from Glance to a block device during copy_image_to_volume, the writes are not committed to disk before it is removed from the SCSI sub-system and then unmapped.
first, we see that the device is found:
{noformat}
Found Fibre Channel volume /dev/sdk (after 1 rescans) connect_volume /usr/lib/python2.6/site-packages/cinder/brick/initiator/connector.py:651
{noformat}
then, we see that it reads the first 512 bytes, we don't know why:
{noformat}
2014-08-05 08:49:36.534 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf sg_scan /dev/sdk execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
2014-08-05 08:49:36.598 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf dd if=/dev/disk/by-path/pci-0000:07:00.0-fc-0x5742b0f000000815-lun-2 of=/dev/null count=1 execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
{noformat}
then, it writes the image on the block device:
{noformat}
2014-08-05 08:49:36.790 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C qemu-img info /var/lib/cinder/conversion/tmpIbAM5q execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
2014-08-05 08:49:40.049 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C qemu-img info /var/lib/cinder/conversion/tmpIbAM5q execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
2014-08-05 08:49:44.053 22122 DEBUG cinder.image.image_utils ... 72897399-6e6e-4238-baf1-1fa4c6de8b71 was qcow2, converting to raw fetch_to_volume_format /usr/lib/python2.6/site-packages/cinder/image/image_utils.py:217
2014-08-05 08:49:44.054 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf qemu-img convert -O raw /var/lib/cinder/conversion/tmpIbAM5q /dev/disk/by-path/pci-0000:07:00.0-fc-0x5742b0f000000815-lun-2 execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
{noformat}
then, it reads the block device to verify;
{noformat}
2014-08-05 08:49:45.121 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C qemu-img info /dev/disk/by-path/pci-0000:07:00.0-fc-0x5742b0f000000815-lun-2 execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
{noformat}
and then it removes the block device and unmaps the volume:
{noformat}
2014-08-05 08:49:45.303 22122 DEBUG cinder.openstack.common.lockutils ... Got semaphore "connect_volume" for method "disconnect_volume"... inner /usr/lib/python2.6/site-packages/cinder/openstack/common/lockutils.py:191
2014-08-05 08:49:45.303 22122 DEBUG cinder.brick.initiator.linuxscsi ... Remove SCSI device(/dev/sdk) with /sys/block/sdk/device/delete remove_scsi_device /usr/lib/python2.6/site-packages/cinder/brick/initiator/linuxscsi.py:58
2014-08-05 08:49:45.304 22122 DEBUG cinder.openstack.common.processutils ... Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf tee -a /sys/block/sdk/device/delete execute /usr/lib/python2.6/site-packages/cinder/openstack/common/processutils.py:142
2014-08-05 08:49:45.810 22122 DEBUG cinder.volume.driver ... volume ad876e38-857d-4149-abeb-cbddc2bc7d63: removing export _detach_volume /usr/lib/python2.6/site-packages/cinder/volume/driver.py:456
{noformat}
then, reporting success:
{noformat}
2014-08-05 08:49:45.811 22122 DEBUG cinder.volume.flows.manager.create_volume ... Downloaded image 72897399-6e6e-4238-baf1-1fa4c6de8b71 ((None, None)) to volume ad876e38-857d-4149-abeb-cbddc2bc7d63 successfully. _copy_image_to_volume /usr/lib/python2.6/site-packages/cinder/volume/flows/manager/create_volume.py:477
2014-08-05 08:49:45.812 22122 DEBUG cinder.volume.flows.manager.create_volume ... Marking volume ad876e38-857d-4149-abeb-cbddc2bc7d63 as bootable. _enable_bootable_flag /usr/lib/python2.6/site-packages/cinder/volume/flows/manager/create_volume.py:417
2014-08-05 08:49:45.869 22122 DEBUG cinder.volume.flows.manager.create_volume ... Copying metadata from image 72897399-6e6e-4238-baf1-1fa4c6de8b71 to ad876e38-857d-4149-abeb-cbddc2bc7d63. _handle_bootable_volume_glance_meta /usr/lib/python2.6/site-packages/cinder/volume/flows/manager/create_volume.py:380
2014-08-05 08:49:45.870 22122 DEBUG cinder.volume.flows.manager.create_volume ... Creating volume glance metadata for volume ad876e38-857d-4149-abeb-cbddc2bc7d63 backed by image 72897399-6e6e-4238-baf1-1fa4c6de8b71 with: {'container_format': u'bare', 'min_ram': 0, 'disk_format': u'qcow2', 'image_name': u'650', 'image_id': u'72897399-6e6e-4238-baf1-1fa4c6de8b71', 'checksum': u'ff3cfedc52decb10a66d61ce457addf3', 'min_disk': 0, 'size': 829095936}. _capture_volume_image_metadata /usr/lib/python2.6/site-packages/cinder/volume/flows/manager/create_volume.py:514
2014-08-05 08:49:46.242 22122 INFO cinder.volume.flows.manager.create_volume ... Volume volume-ad876e38-857d-4149-abeb-cbddc2bc7d63 (ad876e38-857d-4149-abeb-cbddc2bc7d63): created successfully
{noformat}
and that's it.
the problem is that the writes that qemu-img does are not synced/flushed to disk before remove the device.
this piece of code comes from the base-class for volume drivers within Cinder, which means it affects all the volume drivers, not just ours.
as a workaround, we're adding a call to /bin/sync before detaching a volume in the next release of our volume driver.
we managed to write a test that re-creates it and verifies that our workaround fixes this issue.
We are also aware of this issue, and it is affecting our driver as well. This is an important issue that should be receive attention quickly.