Bug 1123316

Summary: YaST2 iSCSI LIO Target does not accept lvm volumes as /dev/vg/lvol for LUN
Product: [openSUSE] openSUSE Distribution Reporter: Andrew Iliady <iliady>
Component: YaST2Assignee: YaST Team <yast-internal>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P3 - Medium CC: ancor, iliady, mloviska, schubi, snwint
Version: Leap 15.0   
Target Milestone: ---   
Hardware: All   
OS: SUSE Other   
URL: https://trello.com/c/0ce5OqPP
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Yast2 logs
yast2-iscsi-lio-server for sle15

Description Andrew Iliady 2019-01-28 10:00:32 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Build Identifier: 

I'm trying to create LUN from LVM volume (as /dev/vg/lvol) for iSCSI LIO Target in Yast2 and get an error "Please provide a normal file or block device". If I give this LVM volume as /dev/dm-X, for which the symlink /dev/vg/lvol is created, it's OK.

Reproducible: Always

Steps to Reproduce:
1.Open YaST2 iSCSI LIO Target - Targets - Add (or Edit) - Add LUN
2.In LUN details select LUN path - Browse and select /dev/vg/lvol
3.Click OK 
Actual Results:  
You get an error "Please provide a normal file or block device"

Expected Results:  
The LVM volume has to be selected for LUN
Comment 2 Andrew Iliady 2019-02-05 05:48:26 UTC
Created attachment 795962 [details]
Yast2 logs
Comment 3 Stefan Schubert 2019-02-05 12:05:44 UTC
Ancor I am not a storage expert, but as far I am remembering we have already had some issues/discussion about "naming". Could you please check this ? Thanks !
Comment 4 Ancor Gonzalez Sosa 2019-02-05 14:26:38 UTC
(In reply to Stefan Schubert from comment #3)
> Ancor I am not a storage expert, but as far I am remembering we have already
> had some issues/discussion about "naming". Could you please check this ?
> Thanks !

I don't think this is related at all to the recent problems with yast-storage-ng and names. The code raising that warning does not use yast-storage-ng or libstorage-ng at all.

See 
https://github.com/yast/yast-iscsi-lio-server/blob/830663122701ec3cb21b85a0b260fd1f757192f9/src/include/iscsi-lio-server/UI_dialogs.rb#L2713

That code uses the Ruby method File.ftype to ensure the path correspond to a real, direct file. And /dev/vg/lvol is not a block special file, but a symlink to one (i.e. File.ftype("/dev/vg/lvol") == "link").

It will work if the user introduces something like "/dev/dm-0" (to know the exact file, check which /dev/dm-X is pointed by /dev/vg/lvol).

So this works as designed so far (accepting only the block special file and complaining if a symlink is provided). Whether we want to teach yast2-iscsi-lio-server to follow symlinks, that's another question.
Comment 5 Steffen Winterfeldt 2019-02-05 15:45:33 UTC
I believe the intention of the code is to ensure only block devs or files are used (versus pipes, char devs, dirs, etc). That it does not follow symlinks is
imho simply a bug.

Probably the fact that ruby's File.ftype does not follow links came as a surprise
to the author (as possibly to nearly everybody).

File.blockdev? || File.file? would do the trick, I guess.
Comment 6 Ladislav Slezák 2019-02-06 15:12:02 UTC
Roger, please take care of this one.
Comment 8 Steffen Winterfeldt 2019-02-19 10:15:05 UTC
It's tracked in YaST Scrum board.
Comment 9 Steffen Winterfeldt 2019-02-20 12:57:46 UTC
fix: https://github.com/yast/yast-iscsi-lio-server/pull/85
Comment 10 Steffen Winterfeldt 2019-02-20 13:15:28 UTC
sle15/leap 15.0 variant: https://github.com/yast/yast-iscsi-lio-server/pull/86

Andrew, it would be very helpful if you could test this patch.
Comment 12 Andrew Iliady 2019-02-22 05:31:04 UTC
I surely would, if you tell me how.
I've never used patches manually before.
Comment 14 Steffen Winterfeldt 2019-02-22 10:39:22 UTC
Created attachment 797595 [details]
yast2-iscsi-lio-server for sle15

Please test the attached package. It's built for sle15, which should be the same as leap 15.0.
Comment 16 Martin Loviska 2019-02-22 14:14:52 UTC
(In reply to Steffen Winterfeldt from comment #9)
> fix: https://github.com/yast/yast-iscsi-lio-server/pull/85

I have taken packages which are mentioned in SR:
* https://build.opensuse.org/request/show/677698

Used repo:
* http://download.suse.de/ibs/Devel:/YaST:/Head/SUSE_SLE-15_GA/Devel:YaST:Head.repo

Tested package:
* yast2-iscsi-lio-server-4.1.3-1.1.noarch.rpm      

Steps to reproduce:
* run yast2 iscsi-lio-server
* open port in fw
* add a target 
  1. disable discovery auth
  2. disable login auth
  3. LUN path: /dev/lvm_lun/iscsi_lv

* partitions layout on target

NAME                 MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                   11:0    1  3.7G  0 rom  
vda                  253:0    0   30G  0 disk 
├─vda1               253:1    0    2M  0 part 
├─vda2               253:2    0   14G  0 part 
│ └─system-lv_root   254:0    0   14G  0 lvm  /
├─vda3               253:3    0   10G  0 part 
│ ├─home-lv_swap     254:1    0    1G  0 lvm  [SWAP]
│ └─home-lv_home     254:2    0    9G  0 lvm  /home
└─vda4               253:4    0    6G  0 part 
  └─lvm_lun-iscsi_lv 254:3    0    6G  0 lvm  

o- / ............................................................. [...]
  o- backstores [...]
  | o- block  [Storage Objects: 1]
  | | o- dev-lvm_lun-iscsi_lv [/dev/lvm_lun/iscsi_lv (6.0GiB) write-thru activated]
  | |   o- alua  [ALUA Groups: 1]
  | |     o- default_tg_pt_gp  [ALUA state: Active/optimized]
  | o- fileio  [Storage Objects: 0]
  | o- pscsi  [Storage Objects: 0]
  | o- ramdisk  [Storage Objects: 0]
  | o- rbd [Storage Objects: 0]
  o- iscsi  [Targets: 1]
  | o- iqn.2019-02.com.test:97ee176200133781a0d3  [TPGs: 1]
  |   o- tpg1  [gen-acls, no-auth]
  |     o- acls  [ACLs: 0]
  |     o- luns  [LUNs: 1]
  |     | o- lun0  [block/dev-lvm_lun-iscsi_lv (/dev/lvm_lun/iscsi_lv) (default_tg_pt_gp)]
  |     o- portals . [Portals: 1]
  |       o- 0.0.0.0:3260  [OK]
  o- loopback  [Targets: 0]
  o- vhost  [Targets: 0]
  o- xen-pvscsi  [Targets: 0]
_________________________________________________

* initiator conf:
1. run yast2 iscsi-client
2. set ip of target 
3. discover available targets
4. create partition fdisk /dev/sda
5. mkfs.ext4 /dev/sda1
6. mount /dev/sda1 /mnt
7. write on iscsi drive

#lsscsi
[0:0:0:0]    cd/dvd  QEMU     QEMU DVD-ROM     2.5+  /dev/sr0 
[6:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sda 

#lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0    6G  0 disk 
└─sda1   8:1    0    6G  0 part /mnt
sr0     11:0    1  3.7G  0 rom  
vda    253:0    0   16G  0 disk 
├─vda1 253:1    0    8M  0 part 
├─vda2 253:2    0   14G  0 part /
└─vda3 253:3    0    2G  0 part [SWAP]

#iscsiadm --mode node session
10.100.51.137:3260,1 iqn.2019-02.com.test:97ee176200133781a0d3

# ls /dev/disk/by-path

ip-10.100.51.137:3260-iscsi-iqn.2019-02.com.test:97ee176200133781a0d3-lun-0
ip-10.100.51.137:3260-iscsi-iqn.2019-02.com.test:97ee176200133781a0d3-lun-0-part1
pci-0000:00:1f.2-ata-1
pci-0000:05:00.0
pci-0000:05:00.0-part1
pci-0000:05:00.0-part2
pci-0000:05:00.0-part3
virtio-pci-0000:05:00.0
virtio-pci-0000:05:00.0-part1
virtio-pci-0000:05:00.0-part2
virtio-pci-0000:05:00.0-part3

Seems that iscsi works with lvm drives as expected
Comment 17 Steffen Winterfeldt 2019-02-22 14:22:04 UTC
Thanks for testing!
Comment 18 Martin Loviska 2019-02-22 15:03:18 UTC
(In reply to Steffen Winterfeldt from comment #17)
> Thanks for testing!

Welcome! I have also created a poo#48329 ticket to add an iscsi test suite to test LVM block device backstore.
Comment 19 Swamp Workflow Management 2019-03-21 23:18:38 UTC
SUSE-RU-2019:0698-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 1123316
CVE References: 
Sources used:
SUSE Linux Enterprise Module for Basesystem 15 (src):    yast2-iscsi-lio-server-4.0.12-3.6.1
Comment 20 Swamp Workflow Management 2019-04-02 10:13:21 UTC
openSUSE-RU-2019:1098-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 1123316
CVE References: 
Sources used:
openSUSE Leap 15.0 (src):    yast2-iscsi-lio-server-4.0.12-lp150.2.6.1

*** NOTE: This information is not intended to be used for external
    communication, because this may only be a partial fix.
    If you have questions please reach out to maintenance coordination.