ceph / ceph-iscsi-cli

NOTICE: moved to https://github.com/ceph/ceph-iscsi
GNU General Public License v3.0
25 stars 25 forks source link

cannot remove client iqn when name it in capital letters, but can be created #146

Open dazhi509 opened 5 years ago

dazhi509 commented 5 years ago

I create a new iqn which is named:iqn.2018-12.com.wz:TEST001, which has capital letters in it, then I try to remove it, the response of it shows ok, but when I exit gwcli, and come in it again, I found it is still here! I try to map it with iscsi in windows OS, and I found that it is not supported capital letters in iqn name, it will turn it in lowercase. I think capital letters should not in iqn name, but it seems that you didn't prevent it, Is that in case?

mikechristie commented 5 years ago

The iSCSI spec says the name is not case sensitive. The kernel and rtslib will take the capital letters and just convert it to lower case. The user space tools are ignoring the normalized name that rtslib returns and will use the name with capital letters. On deletion we then later mismatch and think we already deleted it.

We should be using the name returned from rtslib.normalize_wwn.

I will make a patch and link it here.

mikechristie commented 5 years ago

Here are some patches which should fix the issue:

https://github.com/ceph/ceph-iscsi/pull/12

For your existing setup with the bad name, I think you are stuck. You can manually delete everything by doing

rados -p rbd rm gateway.conf

then rebooting the iscsi gateways. When they come up it will be with a empty config and no objects.

dazhi509 commented 5 years ago

thanks. but I found another issue.

1: I make a image in command rbd create iotest/datest --size 10G ,

2: and then I use gwcli to create an iqn, create iqn.1994-05.com.redhat:75c3d5efde0

3: and create a disk create pool=iotest image=datest size=10G which is the same name as i created in command rbd create iotest/datest --size 10G .

4: i add the disk to my iqn in command disk add iotest.datest

5: after all success, i remove the disk, in curl --insecure --user admin:admin -d disk=iotest.datest -X DELETE https://192.168.122.69:5000/api/clientlun/iqn.2017-08.org.ceph:iscsi-gw0,

6: and remove the iqn curl --insecure --user admin:admin -X DELETE https://192.168.122.69:5000/api/client/iqn.1994-05.com.redhat:myhost4

7: then I remove my image in ceph, by doing rbd rm iotest/datest

it seems ok for all I done, but when I try to come in gwcli again, it shows

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 812, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 765, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/site-packages/gwcli/storage.py", line 76, in _get_disk_size
    with rbd.Image(ioctx, image) as rbd_image:
  File "rbd.pyx", line 1397, in rbd.Image.__init__ (/home/jenkins-build/build/workspace/ceph-build/ARCH/x86_64/AVAILABLE_ARCH/x86_64/AVAILABLE_DIST/centos7/DIST/centos7/MACHINE_SIZE/huge/release/12.2.10/rpm/el7/BUILD/ceph-12.2.10/build/src/pybind/rbd/pyrex/rbd.c:11876)
ImageNotFound: [errno 2] error opening image datest at snapshot None

KeyError: u'iotest.datest'

and gwcli cannot work again! I find in log that the image ` datest is still in config file:

"disks": {
        "iotest.datest": {
            "created": "2019/01/17 01:10:09",
            "image": "datest",
            "owner": "node3",
            "pool": "iotest",
            "pool_id": 7,
            "updated": "2019/01/17 01:10:09",
            "wwn": "f0b79a61-3470-4b2a-b9e9-f8574410fb13"
        }
}

i use targetcli and it shows that the image I created iotest.datest is still there

/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 0]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  | o- user:glfs .............................................................................................. [Storage Objects: 0]
  | o- user:qcow .............................................................................................. [Storage Objects: 0]
  | o- user:rbd ............................................................................................... [Storage Objects: 2]
  |   o- iotest.rbd-01 ...................................................... [iotest/rbd-01;osd_op_timeout=30 (500.0GiB) activated]
  |   | o- alua ................................................................................................... [ALUA Groups: 4]
  |   |   o- ano2 ............................................................................... [ALUA state: Active/non-optimized]
  |   |   o- ano3 ............................................................................... [ALUA state: Active/non-optimized]
  |   |   o- ao ..................................................................................... [ALUA state: Active/optimized]
  |   |   o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]
  |   o- iotest.datest ........................................................... [iotest/datest;osd_op_timeout=30 (10.0GiB) activated]
  |     o- alua ................................................................................................... [ALUA Groups: 4]
  |       o- ano1 ............................................................................... [ALUA state: Active/non-optimized]
  |       o- ano3 ............................................................................... [ALUA state: Active/non-optimized]
  |       o- ao ..................................................................................... [ALUA state: Active/optimized]
  |       o- default_tg_pt_gp ....................................................................... [ALUA state: Active/optimized]

I have suffered from this issue for a while.

I think I cannot delete any ceph image if this image ever map to an iqn in case of gwcli goes wrong.

mikechristie commented 5 years ago

It's not supported to mix different methods.