Project

General

Profile

Bug #4802

open-iscsi iscsiadm throws unrecognized character errors

Added by David Laube over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
-
Target version:
Start date:
10/28/2015
Due date:
% Done:

100%

Estimated time:
Affected versions:
Security IDs:

Description

We are seeing strange behavior while attempting to execute basic functions of the iscsiadm utility under Alpine linux 3.2.3. This seems to impact all iscsi initiator features under Alpine linux.

Steps to reproduce:

apk add open-iscsi
apk add open-iscsi-doc
[See command output after man page examples below]

------------------
Man page for iscsiadm

EXAMPLES
Discover targets at a given IP address:

iscsiadm --mode discoverydb --type sendtargets --portal 192.168.1.10 --discover
...
List node records:
iscsiadm --mode node

------------------
Command output:

localhost:~# iscsiadm --mode discoverydb --type sendtargets --portal 10.144.0.14 --discover
iscsiadm: unrecognized character 'D'
localhost:~# iscsiadm --debug 8 --mode discoverydb --type sendtargets --portal 10.144.0.14 --discover
iscsiadm: ip 10.144.0.14, port -1, tgpt -1
iscsiadm: unrecognized character 'D'
localhost:~# iscsiadm --mode node
iscsiadm: unrecognized character 'm'

Associated revisions

Revision 3d5e7f06 (diff)
Added by Jann - Ove Risvik over 2 years ago

main/open-iscsi: musl fix for error handling. (bug #4802)

fixes #4802

Seems like iscsiadm relies on checking optopt for checking if there's an
error, instead of checking whether opterr is set or if getopt returns
'?' and then using optopt to retrieve the option that it didn't
recognize.

For some reason musl sets optopt to the last option parsed even if it
was valid. Is musl supposed to do that? glibc doesn't behave this way.
The posix standard for getopt also reads like optopt is only supposed to
be set when there's an error.

History

#1 Updated by obligatory name about 3 years ago

argument-handling of iscsiadm works not as expected:

vbox-alpine:~# iscsiadm -a
iscsiadm: option requires an argument: a
iscsiadm: unrecognized character 'a'
vbox-alpine:~# iscsiadm -a -b
iscsiadm: unrecognized character 'a'
vbox-alpine:~# iscsiadm -a -b -c
iscsiadm: option requires an argument: c
iscsiadm: unrecognized character 'c'
vbox-alpine:~# cat /etc/issue
Welcome to Alpine Linux 3.3
Kernel \r on an \m (\l)

vbox-alpine:~# uname -a
Linux vbox-alpine 4.1.15-2-grsec #3-Alpine SMP Tue Jan 5 11:27:22 GMT 2016 x86_64 Linux
vbox-alpine:~# apk info open-iscsi*
open-iscsi-doc-2.0.873-r3 description:
High performance, transport independent, multi-platform iSCSI initiator (documentation)

open-iscsi-doc-2.0.873-r3 webpage:
http://www.open-iscsi.org

open-iscsi-doc-2.0.873-r3 installed size:
40960

open-iscsi-2.0.873-r3 description:
High performance, transport independent, multi-platform iSCSI initiator

open-iscsi-2.0.873-r3 webpage:
http://www.open-iscsi.org

open-iscsi-2.0.873-r3 installed size:
1748992

#2 Updated by obligatory name almost 3 years ago

still the same behaviour with alpine v3.4.0

vbox-alpine:~# iscsiadm -a
iscsiadm: option requires an argument: a
iscsiadm: unrecognized character 'a'
vbox-alpine:~# iscsiadm -a -b
iscsiadm: unrecognized character 'a'
vbox-alpine:~# iscsiadm -a -b -c
iscsiadm: option requires an argument: c
iscsiadm: unrecognized character 'c'
vbox-alpine:~# iscsiadm -a -b -c -d
iscsiadm: unrecognized character 'c'
vbox-alpine:~# iscsiadm -a -b -c -d -e
iscsiadm: unrecognized option: e
iscsiadm: unrecognized character 'e'
vbox-alpine:~# cat /etc/issue
Welcome to Alpine Linux 3.4
Kernel \r on an \m (\l)

vbox-alpine:~# uname -a
Linux vbox-alpine 4.4.11 #1-Alpine SMP Fri May 20 08:56:22 GMT 2016 x86_64 Linux
vbox-alpine:~# apk info open-iscsi*
open-iscsi-doc-2.0.873-r3 description:
High performance, transport independent, multi-platform iSCSI initiator (documentation)

open-iscsi-doc-2.0.873-r3 webpage:
http://www.open-iscsi.org

open-iscsi-doc-2.0.873-r3 installed size:
40960

open-iscsi-2.0.873-r3 description:
High performance, transport independent, multi-platform iSCSI initiator

open-iscsi-2.0.873-r3 webpage:
http://www.open-iscsi.org

open-iscsi-2.0.873-r3 installed size:
1748992

#3 Updated by Jann - Ove Risvik over 2 years ago

Seems like it relies on checking optopt for checking if there's an error, instead of checking whether opterr is set or if getopt returns '?' and then using optopt to retrieve the option that it didn't recognize.

For some reason musl sets optopt to the last option parsed even if it was valid. Is musl supposed to do that? glibc doesn't behave this way. The posix standard for getopt also reads like optopt is only supposed to be set when there's an error.

I've submitted an updated aport that changes the error handling slightly and works around how musl's getopt behaves.

#4 Updated by obligatory name over 2 years ago

Thx for your reply, jann-ove risvik, but i believe your mod doesn't help. i'm using the edge-branch-version of open-iscsi in a very basic and fresh alpine-installation now:

vbox-alpine:~# apk info open-iscsi | head -1
open-iscsi-2.0.873-r4 description:

vbox-alpine:~# cat /etc/alpine-release ; uname -a
3.4.0
Linux vbox-alpine 4.4.11 #1-Alpine SMP Fri May 20 08:56:22 GMT 2016 x86_64 Linux

but using the wiki-howto (https://wiki.alpinelinux.org/wiki/Setting_up_iSCSI) nothing works as expected:
(as far as i remember: using open-iscsi-2.0.873-r3 show's the same strange output)

vbox-alpine:~# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2005-03.org.open-iscsi:198d2149e39

vbox-alpine:~# pgrep -lf iscsi

vbox-alpine:~# /etc/init.d/iscsid start
 * Checking open-iSCSI configuration ...
 * Loading iSCSI modules ...
 * Loading libiscsi ...                                             [ ok ]
 * Loading scsi_transport_iscsi ...                                 [ ok ]
 * Loading iscsi_tcp ...                                            [ ok ]
 * Starting iscsid ...
 * Setting up iSCSI targets ...                                     [ !! ]
 * ERROR: iscsid failed to start

vbox-alpine:~# pgrep -lf iscsi
2018 iscsi_eh
2041 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
2042 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

vbox-alpine:~# /etc/init.d/iscsid stop
 * WARNING: iscsid is already stopped

vbox-alpine:~# pgrep -lf iscsi
2018 iscsi_eh
2041 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
2042 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

vbox-alpine:~# /etc/init.d/iscsid start
 * Checking open-iSCSI configuration ...
 * Loading iSCSI modules ...
 * Loading libiscsi ...                                             [ ok ]
 * Loading scsi_transport_iscsi ...                                 [ ok ]
 * Loading iscsi_tcp ...                                            [ ok ]
 * Starting iscsid ...
 * start-stop-daemon: /usr/sbin/iscsid is already running           [ ok ]

vbox-alpine:~# pgrep -lf iscsi
2018 iscsi_eh
2041 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
2042 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

Furthermore, if i try to get some interaction with my target, it seems like iscsiadm doesn't handle it's arguments:

vbox-alpine:~# ping -c1 192.168.56.10 | egrep 'time|loss'
64 bytes from 192.168.56.10: seq=0 ttl=255 time=1.433 ms
1 packets transmitted, 1 packets received, 0% packet loss

vbox-alpine:~# nmap -sT -p3260 192.168.56.10 | grep open
3260/tcp open  iscsi

vbox-alpine:~# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.10 --discover

vbox-alpine:~# echo $?
7

vbox-alpine:~# man iscsiadm | grep 'invalid arg'
       7      ISCSI_ERR_INVAL - invalid argument.

vbox-alpine:~# iscsiadm -d 8 -m discoverydb -t sendtargets -p 192.168.56.10 -D
iscsiadm: ip 192.168.56.10, port -1, tgpt -1

vbox-alpine:~# echo $?
7

but:

vbox-alpine:~# iscsi_discovery 192.168.56.10 -d
starting discovery to 192.168.56.10
Testing tcp-login to target portal
Cannot login over tcp to portal
starting to test tcp-login to target portal
Cannot login over tcp to portal
discovered 1 targets at 192.168.56.10

vbox-alpine:~# echo $?
0

and if i try to stop the service, it's stopped (sometimes, because watch the example above, it stops not everytime), but the PIDFILE isn't deleted and the output looks not like expected:

vbox-alpine:~# pgrep -lf iscsi
2018 iscsi_eh
9520 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
9521 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

vbox-alpine:~# cat /var/run/iscsid.pid
9521

vbox-alpine:~# grep PID /etc/init.d/iscsid
        start-stop-daemon --signal HUP --stop --quiet --exec /usr/sbin/iscsid #--pidfile $PID_FILE
        rm -f $PID_FILE

vbox-alpine:~# /etc/init.d/iscsid -d -v stop
 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/iscsid stop
+ _conf_d=/etc/init.d/../conf.d
+ _c=iscsid
+ [ -n iscsid -a iscsid != iscsid ]
+ unset _c
+ sourcex -e /etc/init.d/../conf.d/iscsid.default
+ [ -e = -e ]
+ shift
+ [ -e /etc/init.d/../conf.d/iscsid.default ]
+ return 1
+ sourcex -e /etc/init.d/../conf.d/iscsid
+ [ -e = -e ]
+ shift
+ [ -e /etc/init.d/../conf.d/iscsid ]
+ . /etc/init.d/../conf.d/iscsid
+ CONFIG_FILE=/etc/iscsi/iscsid.conf
+ INITIATORNAME_FILE=/etc/iscsi/initiatorname.iscsi
+ OPTS=-i /etc/iscsi/initiatorname.iscsi
+ AUTOSTARTTARGETS=yes
+ unset _conf_d
+ sourcex -e /etc/rc.conf
+ [ -e = -e ]
+ shift
+ [ -e /etc/rc.conf ]
+ . /etc/rc.conf
+ rc_tty_number=12
+ [ -d /etc/rc.conf.d ]
+ sourcex /lib/rc/sh/s6.sh
+ [ /lib/rc/sh/s6.sh = -e ]
+ . /lib/rc/sh/s6.sh
+ [ -z  ]
+ s6_service_path=/var/svc.d/iscsid
+ sourcex /lib/rc/sh/start-stop-daemon.sh
+ [ /lib/rc/sh/start-stop-daemon.sh = -e ]
+ . /lib/rc/sh/start-stop-daemon.sh
+ sourcex /lib/rc/sh/supervise-daemon.sh
+ [ /lib/rc/sh/supervise-daemon.sh = -e ]
+ . /lib/rc/sh/supervise-daemon.sh
+ yesno
+ [ -z  ]
+ return 1
+ [ stop != status -a stop != describe ]
+ [ -n  ]
+ command -v cgroup_add_service
+ [ cgroup_add_service = cgroup_add_service ]
+ [ -d /sys/fs/cgroup -a ! -w /sys/fs/cgroup ]
+ cgroup_add_service /sys/fs/cgroup/openrc
+ [ -f /sys/fs/cgroup/blkio/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpu/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpuacct/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpuset/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/devices/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/freezer/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/memory/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/net_cls/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/net_prio/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/openrc/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/pids/tasks ]
+ printf %d 0
+ openrc_cgroup=/sys/fs/cgroup/openrc
+ [ -d /sys/fs/cgroup/openrc ]
+ cgroup=/sys/fs/cgroup/openrc/iscsid
+ mkdir -p /sys/fs/cgroup/openrc/iscsid
+ [ -f /sys/fs/cgroup/openrc/iscsid/tasks ]
+ printf %d 0
+ cgroup_add_service /sys/fs/cgroup/systemd/system
+ [ -f /sys/fs/cgroup/blkio/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpu/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpuacct/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/cpuset/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/devices/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/freezer/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/memory/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/net_cls/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/net_prio/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/openrc/tasks ]
+ printf %d 0
+ [ -f /sys/fs/cgroup/pids/tasks ]
+ printf %d 0
+ openrc_cgroup=/sys/fs/cgroup/openrc
+ [ -d /sys/fs/cgroup/openrc ]
+ cgroup=/sys/fs/cgroup/openrc/iscsid
+ mkdir -p /sys/fs/cgroup/openrc/iscsid
+ [ -f /sys/fs/cgroup/openrc/iscsid/tasks ]
+ printf %d 0
+ command -v cgroup_set_limits
+ [ cgroup_set_limits = cgroup_set_limits ]
+ cgroup_set_limits
+ local blkio=
+ [ -n  ]
+ local cpu=
+ [ -n  ]
+ local cpuacct=
+ [ -n  ]
+ local cpuset=
+ [ -n  ]
+ local devices=
+ [ -n  ]
+ local hugetlb=
+ [ -n  ]
+ local memory=
+ [ -n  ]
+ local net_cls=
+ [ -n  ]
+ local net_prio=
+ [ -n  ]
+ local pids=
+ [ -n  ]
+ return 0
+ break
+ sourcex /etc/init.d/iscsid
+ [ /etc/init.d/iscsid = -e ]
+ . /etc/init.d/iscsid
+ extra_started_commands=starttargets stoptargets restarttargets
+ read _d
+ eval printf '%s\n'
+ printf %s\n
+ [ -n  ]
+ read _d
+ [ 0 -ne 0 ]
+ unset _d
+ read _f
+ eval printf '%s\n'
+ printf %s\n
+ [ -n  ]
+ read _f
+ [ 0 -ne 0 ]
+ unset _f
+ [ -n  ]
+ [ -n stop ]
+ [ stop = depend ]
+ [ describe = stop ]
+ [ start = stop ]
+ [ stop = stop ]
+ command -v stop
+ [ stop = stop ]
+ yesno
+ [ -z  ]
+ return 1
+ [ starttargets = stop ]
+ [ stoptargets = stop ]
+ [ restarttargets = stop ]
+ [ cgroup_cleanup = stop ]
+ unset _cmd
+ verify_boot
+ [ ! -e /run/openrc/softlevel ]
+ return 0
+ command -v stop_pre
+ [  = stop_pre ]
+ stop
+ local ret=
+ stoptargets
+ ebegin Disconnecting iSCSI targets
 * Disconnecting iSCSI targets ...
+ sync
+ /usr/bin/iscsiadm -m node --logoutall=all
+ ret=7
+ eend 7                                                            [ !! ]
+ return 7
+ ebegin Stopping iscsid
 * Stopping iscsid ...
+ start-stop-daemon --signal HUP --stop --quiet --exec /usr/sbin/iscsid
 * Will stop /usr/sbin/iscsid
 * Will stop processes of `/usr/sbin/iscsid'
 * Sending signal 1 to PID 9521 ...                                 [ ok ]
 * Sending signal 1 to PID 9520 ...                                 [ ok ]
+ ret=0
+ eend 0                                                            [ ok ]
+ rm -f
+ return 0
+ command -v stop_post
+ [  = stop_post ]
+ command -v cgroup_cleanup
+ [ cgroup_cleanup = cgroup_cleanup -a stop = stop ]
+ yesno
+ [ -z  ]
+ return 1
+ shift
+ continue 2
+ [ -n  ]
+ exit 0

vbox-alpine:~# pgrep -lf iscsi
2018 iscsi_eh

vbox-alpine:~# ls -l /var/run/iscsid.pid
-rw-------    1 root     root             5 Jul 13 17:41 /var/run/iscsid.pid

vbox-alpine:~# cat /var/run/iscsid.pid
9521

vbox-alpine:~# /etc/init.d/iscsid status
 * Showing current active iSCSI sessions ...

The wiki says iscsi worked with alpine 2.4, so i was setting up an installation with 2.4.11 and recognized, the iscsi_discovery is broken in the same way it is in 3.4.0. but i get a absolut different output for the same target:

alpinezwei:~# cat /etc/alpine-release ; uname -a
2.4.11
Linux alpinezwei 3.4.46-grsec #1-Alpine SMP Mon May 20 11:14:09 UTC 2013 x86_64 Linux

alpinezwei:~# apk info open-iscsi | head -1
open-iscsi-2.0.872-r3 description:

alpinezwei:~# iscsi_discovery 192.168.56.10 -d
-ash: iscsi_discovery: not found

alpinezwei:~# which iscsi_discovery
/usr/bin/iscsi_discovery

alpinezwei:~# /usr/bin/iscsi_discovery 192.168.56.10 -d
-ash: /usr/bin/iscsi_discovery: not found

alpinezwei:~# apk add bash bash-doc
(1/5) Installing ncurses-base (5.9-r1)
(2/5) Installing ncurses-libs (5.9-r1)
(3/5) Installing readline (6.2.002-r0)
(4/5) Installing bash (4.2.037-r0)
(5/5) Installing bash-doc (4.2.037-r0)
Executing busybox-1.19.4-r6.trigger
Executing uclibc-utils-0.9.33.1-r1.trigger
OK: 167 MiB in 38 packages

alpinezwei:~# bash iscsi_discovery 192.168.56.10 -d
iscsiadm: No active sessions.
starting discovery to 192.168.56.10
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.10:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.10:3260
Logging out of session [sid: 1, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260]
Logout of [sid: 1, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] successful.
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.20:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.20:3260
Logging out of session [sid: 2, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260]
Logout of [sid: 2, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260] successful.
discovered 2 targets at 192.168.56.10

alpinezwei:~# echo $0
-ash

alpinezwei:~# iscsi_discovery 192.168.56.10 -d
iscsiadm: No active sessions.
starting discovery to 192.168.56.10
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.10:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.10:3260
Logging out of session [sid: 3, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260]
Logout of [sid: 3, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] successful.
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.20:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.20:3260
Logging out of session [sid: 4, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260]
Logout of [sid: 4, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260] successful.
discovered 2 targets at 192.168.56.10

so ... maybe ash isn't the best choice for a default shell for newbies like me?

anyway. something happened in the development between alpine v2.4.11 and v3.2.3 which breaks open-iscsi. there is a lot of unexpected behaviour, but i don't have an idea what i'm talking about. ATM i try to learn some iscsi, but it's hard under such circumstances. i will also try alpine v3.4.1 tomorrow and do some config-tests...

#5 Updated by obligatory name over 2 years ago

It work's with Alpine v2.7.9 and it's default (main) repo-open-iscsi-package

alpine279:~# cat /etc/alpine-release ; uname -a
2.7.9
Linux alpine279 3.10.52-0-grsec #1-Alpine SMP Tue Aug 12 06:08:58 UTC 2014 x86_64 Linux

alpine279:~# apk info open-iscsi | head -1
open-iscsi-2.0.873-r1 description:

No Error while starting the service:

alpine279:~# /etc/init.d/iscsid start
 * Caching service dependencies ...                                                                                                                                       [ ok ]
 * Checking open-iSCSI configuration ...
 * Loading iSCSI modules ...
 * Loading libiscsi ...                                                                                                                                                   [ ok ]
 * Loading scsi_transport_iscsi ...                                                                                                                                       [ ok ]
 * Loading iscsi_tcp ...                                                                                                                                                  [ ok ]
 * Starting iscsid ...
 * Setting up iSCSI targets ...
iscsiadm: No records found                                                                                                                                                [ ok ]

alpine279:~# pgrep -lf iscsi
1239 iscsi_eh
1262 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
1263 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

iscsi_discovery is buggy:

alpine279:~# iscsi_discovery 192.168.56.10 -d
-ash: iscsi_discovery: not found

alpine279:~# bash iscsi_discovery 192.168.56.10 -d
iscsiadm: No active sessions.
starting discovery to 192.168.56.10
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.10:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.10:3260
Logging out of session [sid: 1, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260]
Logout of [sid: 1, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] successful.
Testing tcp-login to target iqn.1992-08.com.netapp:sn.4082368508 portal 192.168.56.20:3260
Set target iqn.1992-08.com.netapp:sn.4082368508 to automatic login over tcp to portal 192.168.56.20:3260
Logging out of session [sid: 2, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260]
Logout of [sid: 2, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.20,3260] successful.
discovered 2 targets at 192.168.56.10

the argument-handling is a bit unexpected:

alpine279:~# iscsiadm -a
iscsiadm: option requires an argument -- a
iscsiadm: unrecognized character 'a'
alpine279:~# iscsiadm -a -b
Try `iscsiadm --help' for more information.
alpine279:~# iscsiadm -a -b -c
iscsiadm: option requires an argument -- c
iscsiadm: unrecognized character 'c'
alpine279:~# iscsiadm -a -b -c -d
Try `iscsiadm --help' for more information.

but iscsi works:

alpine279:~# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.10 --discover
192.168.56.10:3260,1000 iqn.1992-08.com.netapp:sn.4082368508
192.168.56.20:3260,1001 iqn.1992-08.com.netapp:sn.4082368508

alpine279:~# iscsiadm -m node -T iqn.1992-08.com.netapp:sn.4082368508 -p 192.168.56.10:3260 --login
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] (multiple)
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] successful.

alpine279:~# ls -l /dev/sdb
brw-rw----    1 root     disk        8,  16 Jul 15 14:56 /dev/sdb

#6 Updated by obligatory name over 2 years ago

let's do some trial and error...

NOT AVAILABLE:

Alpine v3.0.x (can't find open-iscsi-package. neither in main nor in testing)

WORKING:

Alpine v3.1.4 with OpenISCSI 2.0.873-r2 (main-repo)

alpine314:~# /etc/init.d/iscsid start
 * Caching service dependencies ...                                                 [ ok ]
 * Checking open-iSCSI configuration ...
 * Loading iSCSI modules ...
 * Loading libiscsi ...                                                             [ ok ]
 * Loading scsi_transport_iscsi ...                                                 [ ok ]
 * Loading iscsi_tcp ...                                                            [ ok ]
 * Starting iscsid ...
 * Setting up iSCSI targets ...
iscsiadm: No records found                                                          [ ok ]

alpine314:~# pgrep -lf iscsi
1607 iscsi_eh
1630 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
1631 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

alpine314:~# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.10 --discover
192.168.56.10:3260,1000 iqn.1992-08.com.netapp:sn.4082368508
192.168.56.20:3260,1001 iqn.1992-08.com.netapp:sn.4082368508

alpine314:~# iscsiadm -m node -T iqn.1992-08.com.netapp:sn.4082368508 -p 192.168.56.10:3260 --login
Logging in to [iface: default, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] (multiple)
Login to [iface: default, target: iqn.1992-08.com.netapp:sn.4082368508, portal: 192.168.56.10,3260] successful.

alpine314:~# ls -l /dev/sdb
brw-rw----    1 root     disk        8,  16 Jul 15 17:03 /dev/sdb

releases

alpine314:~# cat /etc/alpine-release ; uname -a
3.1.4
Linux alpine314 3.14.51-0-grsec #1-Alpine SMP Wed Sep 9 08:58:33 GMT 2015 x86_64 Linux

alpine314:~# apk info open-iscsi | head -1
open-iscsi-2.0.873-r2 description:

BROKEN:

Alpine 3.4.1 Extended with OpenISCSI 2.0.873-r3 (main-repo)

alpine341e:~# cat /etc/alpine-release ; uname -a
3.4.1
Linux alpine341e 4.4.14-0-grsec #1-Alpine SMP Mon Jun 27 14:04:45 GMT 2016 x86_64 Linux

alpine341e:~# apk info open-iscsi | head -1
open-iscsi-2.0.873-r3 description:

alpine341e:~# /etc/init.d/iscsid start
 * Caching service dependencies ...                                                 [ ok ]
 * Checking open-iSCSI configuration ...
 * Loading iSCSI modules ...
 * Loading libiscsi ...                                                             [ ok ]
 * Loading scsi_transport_iscsi ...                                                 [ ok ]
 * Loading iscsi_tcp ...                                                            [ ok ]
 * Starting iscsid ...
 * Setting up iSCSI targets ...
iscsiadm: unrecognized character 'L'                                                [ !! ]
 * ERROR: iscsid failed to start

alpine341e:~# pgrep -lf iscsi
2194 iscsi_eh
2217 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi
2218 /usr/sbin/iscsid -i /etc/iscsi/initiatorname.iscsi

alpine341e:~# iscsiadm --mode discoverydb --type sendtargets --portal 192.168.56.10 --discover
iscsiadm: unrecognized character 'D'

I tried to use open-iscsi v2.0.873-r2 in Alpine v3.4.1 Extended by changing the main-repo-path from v3.4 to v3.1. The Installation was successful but starting the service and discover ends both up in the same errors. I believe with Alpine v3.2 something changed in the OS which breaks the open-iscsi-Package. And i also believe the update to open-iscsi-2.0.873-r4 (whatever changed) was not necessary.

I was using VirtualBox v4.3.20 in all cases and the config-files in /etc/iscsi are always the same.

#7 Updated by Jann - Ove Risvik over 2 years ago

The changes in r4 fixes what gives the unrecognized character error, and I've narrowed down why it breaks and verified that it actually works afterwards. ( http://patchwork.alpinelinux.org/patch/2201/ )

obligatory name: it seems like you're correct when you say that something changed in the os after 3.1.4 - and that something seems to be that musl getopt sets optopt even in cases where there's no error. Musl does what it's supposed to do, in 3.1.4

This short snippet tests how getopt behaves, and prints optopt everytime it parses an option:

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main (int argc, char **argv) {
int aflag = 0;
int bflag = 0;
char *cvalue = NULL;
int index;
int c;
optopt = 0;
opterr = 0;
while ((c = getopt (argc, argv, "abc:")) != -1) {
printf ("opt = %c - optopt: %c\n",c, optopt);
}
}

Alpine 3.1.4 does the right thing:

localhost:~$ ./a.out -a -e
opt = a - optopt:
opt = ? - optopt: e
localhost:~$ cat /etc/issue
Welcome to Alpine Linux 3.1
Kernel \r on an \m (\l)

localhost:~$ ./a.out -a -e
opt = a - optopt:
opt = ? - optopt: e

vs Alpine 3.4, where optopt gets set for every option parsed, even valid ones.

usaklig-alpine:~$ cat /etc/issue
Welcome to Alpine Linux 3.4
Kernel \r on an \m (\l)

usaklig-alpine:~$ ./a.out -a -e
opt = a - optopt: a
opt = ? - optopt: e

Debian, for glibc comparison:

jo@debian:~$ cat /etc/issue
Debian GNU/Linux 8 \n \l

jo@debian:~$ ./a.out -a -e
opt = a - optopt:
opt = ? - optopt: e

Iscsiadm relies on optopt for checking if there's an error, and it trusts it to behave per posix specs and only set optopt when there's unrecognized arguments.

#8 Updated by Jann - Ove Risvik over 2 years ago

Hm. I'm sure got it working to the point where I could connect a target here, with just what's in r4. But now that I try again, it doesn't work. There's more to it :/ Will take a second look at it.

#9 Updated by Jann - Ove Risvik over 2 years ago

Okay. What happened was that I got it working - and then I noticed how the easy fix made it silently accept unknown arguments. When fixing that, I broke... everything. :/

It works again here, and I've submitted a patch.

Output from it working as expected:

usaklig-alpine-dev:~# iscsiadm --mode discovery --type sendtargets --portal 192
.168.20.129
192.168.238.1:3260,1 iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9
192.168.20.129:3260,1 iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9
usaklig-alpine-dev:~# iscsiadm --mode node --targetname iqn.2003-01.org.linux-i
scsi.usaklig-alpine-dev-iscsi-target.x8664:sn.37504b4f7de9 --portal 192.168.20.1
29:3260 --login
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260] (multiple)
iscsiadm: Could not login to [iface: default, target: iqn.2003-01.org.linux-iscsi.usaklig->alpine-dev-iscsi-target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260].
iscsiadm: initiator reported error (24 - iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals
usaklig-alpine-dev:~# iscsiadm --mode node --targetname iqn.2003-01.org.linux-i
scsi.usaklig-alpine-dev-iscsi-target.x8664:sn.37504b4f7de9 --portal 192.168.20.1
29:3260 --login
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260] successful.
usaklig-alpine-dev:~# iscsiadm --mode node --targetname iqn.2003-01.org.linux-i
scsi.usaklig-alpine-dev-iscsi-target.x8664:sn.37504b4f7de9 --portal 192.168.20.1
29:3260 --logout
Logging out of session [sid: 3, target: iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260]
Logout of [sid: 3, target: iqn.2003-01.org.linux-iscsi.usaklig-alpine-dev-iscsi->target.x8664:sn.37504b4f7de9, portal: 192.168.20.129,3260] successful.
usaklig-alpine-dev:~#

(And yes, the exported luns show up, and work. This time I tested it well.)

#10 Updated by Garth Booth over 2 years ago

Is there an easy way to build and test this fix with a new alpine container? I'm testing a new container based off of Alpine that is hitting this error and would very much like to get test in my env. Also, is there an estimate on when an official alpine image will have this fix?

#11 Updated by Jann - Ove Risvik over 2 years ago

Sure.

git clone git://dev.alpinelinux.org/aports
abuild-keygen a -i
sudo apk add alpine-sdk
cd aports
wget http://patchwork.alpinelinux.org/patch/2248/raw/ -O
| patch -p1 --dry-run
cd main/open-iscsi/
abuild -r

When that's done you can test it in other alpine installs by either copying the key generated by abuild-keygen, or just use apk's --allow-untrusted.

I don't know how quickly it will show up in an official image.

#12 Updated by Garth Booth over 2 years ago

Awesome, thanks Jann! I'll give this a try. Very much appreciated.

Garth

#13 Updated by Garth Booth over 2 years ago

Hi Jann, after much trial-and-error I was finally able to build a package and install it on an alpine container I deployed. The fix works!

Thanks again,

Garth

#14 Updated by Natanael Copa over 2 years ago

  • Target version set to 3.4.3

#15 Updated by Jann - Ove Risvik over 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

#16 Updated by Natanael Copa over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF