[Bug 1755858] Re: iscsid autostarts on all servers when it has nothing to do

 Christian Ehrhardt  1755858 at bugs.launchpad.net
Wed May 23 12:03:34 UTC 2018


Status of a clean install in a VM and/or Container, so testable rather
trivial:

$ systemctl status iscsid open-iscsi
● iscsid.service - iSCSI initiator daemon (iscsid)
   Loaded: loaded (/lib/systemd/system/iscsid.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-05-23 10:52:11 UTC; 7min ago
     Docs: man:iscsid(8)
  Process: 751 ExecStart=/sbin/iscsid (code=exited, status=0/SUCCESS)
  Process: 721 ExecStartPre=/lib/open-iscsi/startup-checks.sh (code=exited, status=0/SUCCESS)
 Main PID: 759 (iscsid)
    Tasks: 2 (limit: 548)
   CGroup: /system.slice/iscsid.service
           ├─754 /sbin/iscsid
           └─759 /sbin/iscsid

May 23 10:52:11 b1 systemd[1]: Starting iSCSI initiator daemon (iscsid)...
May 23 10:52:11 b1 systemd[1]: iscsid.service: Failed to parse PID from file /run/iscsid.pid: Invalid argument
May 23 10:52:11 b1 iscsid[754]: iSCSI daemon with pid=759 started!
May 23 10:52:11 b1 systemd[1]: Started iSCSI initiator daemon (iscsid).


● open-iscsi.service - Login to default iSCSI targets
   Loaded: loaded (/lib/systemd/system/open-iscsi.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
Condition: start condition failed at Wed 2018-05-23 10:52:11 UTC; 7min ago
           ├─ ConditionDirectoryNotEmpty=|/etc/iscsi/nodes was not met
           └─ ConditionDirectoryNotEmpty=|/sys/class/iscsi_session was not met
     Docs: man:iscsiadm(8)
           man:iscsid(8)


It is important to note that these are not "the same" service twice.
both belong to the same package:
dpkg -S /lib/systemd/system/open-iscsi.service /lib/systemd/system/iscsid.service
open-iscsi: /lib/systemd/system/open-iscsi.service
open-iscsi: /lib/systemd/system/iscsid.service

But the two are doing rather different things:
open-iscsi.service: logs into iSCSI targets if some are configured (Condition stops it from doing so) - this is more a one-shot configure-devices and not a real service
iscsi.service: the basic service daemone, required by the service above

I think here we might learn from Fedora:
Default is:
[root at fedora ~]# systemctl status iscsid.socket iscsid.service
● iscsid.socket - Open-iSCSI iscsid Socket
   Loaded: loaded (/usr/lib/systemd/system/iscsid.socket; enabled; vendor preset: disabled)
   Active: active (listening) since Wed 2018-05-23 11:26:37 UTC; 9s ago
     Docs: man:iscsid(8)
           man:iscsiadm(8)
   Listen: @ISCSIADM_ABSTRACT_NAMESPACE (Stream)

May 23 11:26:37 fedora systemd[1]: Listening on Open-iSCSI iscsid
Socket.

● iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:iscsid(8)
           man:iscsiadm(8)

May 23 11:26:09 fedora systemd[1]: iscsid.service: Failed to reset devices.list: Operation not permitted
May 23 11:26:09 fedora systemd[1]: Starting Open-iSCSI...


And the related config in /etc/iscsid.conf says:
# Use socket activation, but try to make sure the socket units are listening
iscsid.startup = /bin/systemctl start iscsid.socket iscsiuio.socket
(We don't have the uio, but you get the idea - initially only ensure the socket runs.)

The socket then does:
# systemctl cat iscsid.socket
# /usr/lib/systemd/system/iscsid.socket
[Unit]
Description=Open-iSCSI iscsid Socket
Documentation=man:iscsid(8) man:iscsiadm(8)

[Socket]
ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE

[Install]
WantedBy=sockets.target


The tools will reach that and activate the service:
# surely fails and does nothing, but activates the service
$ iscsiadm -m discovery -t st -p 1.2.3.4

Afterwards:
● iscsid.service - Open-iSCSI
   Loaded: loaded (/usr/lib/systemd/system/iscsid.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2018-05-23 11:30:41 UTC; 7s ago


So far our logic is inverse:
1. we start iscsid always
2. we pre-check if it is starte din open-iscsid
   ExecStartPre=/bin/systemctl --quiet is-active iscsid.service

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to open-iscsi in Ubuntu.
https://bugs.launchpad.net/bugs/1755858

Title:
  iscsid autostarts on all servers when it has nothing to do

Status in open-iscsi package in Ubuntu:
  Triaged
Status in open-iscsi source package in Bionic:
  Triaged

Bug description:
  In bionic, the open-iscsi systemd unit has the following guards to
  keep it from running on systems with no iscsi targets configured:

  # Must have some pre-defined targets to login to
  ConditionDirectoryNotEmpty=|/etc/iscsi/nodes
  # or have a session to use via iscsid
  ConditionDirectoryNotEmpty=|/sys/class/iscsi_session

  However, iscsid starts from a separate unit and does not include this
  check.  Thus, iscsid starts on every Ubuntu Server install, whether or
  not it has anything to do.

  We should replicate these unit conditionals to the iscsid unit, to
  ensure the daemon doesn't run (consuming memory, and slowing boot)
  when not needed.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/open-iscsi/+bug/1755858/+subscriptions



More information about the foundations-bugs mailing list