IOError: [Errno 13] Permission denied: u'/dev/cinder-volumes

Asked by Marco CONSONNI

Hello,

I'm using Cinder downloaded from Folsom stable release.

All the daemons (cinder-api, cinder-volume and cinder-scheduler) run on a single machine where I also installed lvm2, iscsitarget open-iscsi, iscsitarget-dkms.

Before using the daemons, I prepared the volume group as expected by cinder:

dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=2G # create a file for hosting the volumes
losetup /dev/loop2 cinder-volumes # setup the loop device
fdisk /dev/loop2 # prepare partition tables
n
p
1
ENTER
ENTER
t
8e
w
pvcreate /dev/loop2
vgcreate cinder-volumes /dev/loop2

Then I restarted target and initiator:

service tgt start
service open-iscsi start

 I restarted cinder's daemons.

When I try to create a volume, the command fails even if the volume gets created.
Why?

This is the volume that's created:

root@OpenStack01:/var/log/cinder# lvdisplay
  --- Logical volume ---
  LV Name /dev/cinder-volumes/volume-3761e161-7b13-4815-b3f4-a4f5fb4f516d
  VG Name cinder-volumes
  LV UUID 9Hybky-d3II-Vlgh-TzmB-57jQ-Gaj5-P7YY73
  LV Write Access read/write
  LV Status available
  # open 1
  LV Size 1.00 GiB
  Current LE 256
  Segments 1
  Allocation inherit
  Read ahead sectors auto
  - currently set to 256
  Block device 252:0

This is the error I get in the log:

2012-11-09 18:09:17 10596 ERROR cinder.openstack.common.rpc.amqp [-] Exception during message handling
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp Traceback (most recent call last):
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/openstack/common/rpc/amqp.py", line 276, in _process_data
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp rval = self.proxy.dispatch(ctxt, version, method, **args)
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/openstack/common/rpc/dispatcher.py", line 145, in dispatch
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp return getattr(proxyobj, method)(ctxt, **kwargs)
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/volume/manager.py", line 163, in create_volume
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp volume_ref['id'], {'status': 'error'})
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp self.gen.next()
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/volume/manager.py", line 156, in create_volume
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp model_update = self.driver.create_export(context, volume_ref)
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/volume/driver.py", line 380, in create_export
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp volume_path)
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp File "/usr/lib/python2.7/dist-packages/cinder/volume/iscsi.py", line 125, in create_iscsi_target
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp f = open(volume_path, 'w+')
2012-11-09 18:09:17 10596 TRACE cinder.openstack.common.rpc.amqp IOError: [Errno 13] Permission denied: u'/dev/cinder-volumes/volume-3761e161-7b13-4815-b3f4-a4f5fb4f516d'

Question information

Language:
English Edit question
Status:
Solved
For:
Cinder Edit question
Assignee:
No assignee Edit question
Solved by:
Marco CONSONNI
Solved:
Last query:
Last reply:
Revision history for this message
Marco CONSONNI (marco-consonni) said :
#1

I looked in the code ("/usr/lib/python2.7/dist-packages/cinder/volume/iscsi.py").
I can't understand the reason why method create_iscsi_target of class TgtAdm tries to write into the just created logical volume as if it were a regular file:

        f = open(volume_path, 'w+')
        f.write(volume_conf)
        f.close()

Revision history for this message
Marco CONSONNI (marco-consonni) said :
#2

I found where the problem was.

When cinder-volume is integrated with tgt (http://stgt.sourceforge.net/) it uses a directory to write a tgt configuration file for each volume that's created.

This means that when you create a volume cinder-volumes creates two objects:

-- the logical volume
-- a file that describes the logical volume for tgt

This directory where the file descriptor is created is defined using the configuration flag volumes_dir or state_path in cinder.conf.

I mistakenly set volumes_dir to the same directory where the logical volumes were created.

This originated the error.