Bug 643092

Summary: Never forgets iscsi sessions & silently logs back in upon network activation
Product: [Fedora] Fedora Reporter: Daniel Berrange <berrange>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: berrange, clalance, crobinso, hdegoede, itamar, jforbes, mchristi, veillard, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 652730 (view as bug list) Environment:
Last Closed: 2011-01-23 23:25:10 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Attachments:
Description Flags
Clearer log of the command sequence to demonstrate problem none

Description Daniel Berrange 2010-10-14 11:43:22 EDT
Description of problem:
Every time i resume from suspend, previous iscsi session I've logged out off, get re-activated.

AFAICT, the iscsi initiator saves details of the iSCSI target in /var/lib/iscsi/nodes. Whenever network manager activates an interface (eg resuming from suspend), /etc/init.d/iscsi will login to any targets listed in /var/lib/iscsi/nodes, even if they were *not* logged into previously.

eg, 

[root@t500wlan ~]# iscsiadm -m session
iscsiadm: No active sessions.
[root@t500wlan ~]# find /var/lib/iscsi/nodes/
/var/lib/iscsi/nodes/
[root@t500wlan ~]# /sbin/iscsiadm --mode discovery --type sendtargets --portal 192.168.254.185:3260,1
192.168.254.185:3260,1 iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84
[root@t500wlan ~]# /sbin/iscsiadm --mode node --portal 192.168.254.185:3260,1 --targetname iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84 --loginLogging in to [iface: default, target: iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84, portal: 192.168.254.185,3260]
Login to [iface: default, target: iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84, portal: 192.168.254.185,3260] successful.
[root@t500wlan ~]# find /var/lib/iscsi/nodes/
/var/lib/iscsi/nodes/
/var/lib/iscsi/nodes/iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84
/var/lib/iscsi/nodes/iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84/192.168.254.185,3260,1
/var/lib/iscsi/nodes/iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84/192.168.254.185,3260,1/default
[root@t500wlan ~]# iscsiadm -m session
tcp: [10] 192.168.254.185:3260,1 iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84
[root@t500wlan ~]# /sbin/iscsiadm --mode node --portal 192.168.254.185:3260,1 --targetname iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84 --logout
Logging out of session [sid: 10, target: iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84, portal: 192.168.254.185,3260]
Logout of [sid: 10, target: iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84, portal: 192.168.254.185,3260] successful.
[root@t500wlan ~]# iscsiadm -m session
iscsiadm: No active sessions.
[root@t500wlan ~]# /etc/init.d/iscsi start
Starting iscsi:                                            [  OK  ]
[root@t500wlan ~]# iscsiadm -m session
tcp: [11] 192.168.254.185:3260,1 iqn.2004-04.com.qnap:ts-439proii:iscsi.berrangehome.bf6d84

It absolutely should *NOT* have activated the session in that last step, since I had explicitly logged out of the iscsi session.


Version-Release number of selected component (if applicable):
iscsi-initiator-utils-6.2.0.872-7.fc13.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Login to an iscsi session
2. Logout of the iscsi session
3. /etc/init.d/iscsi start
  
Actual results:
It activates sessions that were logged out of

Expected results:
Logged out sessions, remain logged out.

Additional info:
Comment 1 Daniel Berrange 2010-10-14 11:45:42 EDT
Created attachment 453499 [details]
Clearer log of the command sequence to demonstrate problem

Bugzilla munged the line endings in the initial description. Attached a clearer copy of the command sequence.
Comment 2 Mike Christie 2010-10-14 16:25:00 EDT
/etc/init.d/iscsi start logs into all portals with the node.startup = automatic. If instead of that script controlling startup, you should mark the startup = manual.

If that does not help or what you were looking for, then we need something completely different, because this is just how the tools/daemon/script work. The iscsiadm login/logout command just tells the kernel to login/logout a sessions it does not control the /etc/init.d/iscsi script's startup behavior. And normally if you were to logout a session with iscsiadm then ran /etc/init.d/iscsi start, users expect the node.startup setting to indicate that the session should be logged in (users use the script to log into the sessions instead of running iscsiadm).
Comment 3 Mike Christie 2010-10-14 16:26:49 EDT
Oh yeah, to set the startup you can edit /etc/iscsi/iscsid.conf's node.startup, then rediscover the iscsi portals (when you discover the portals the new iscsid.conf setttings get picked up).

Or run iscsiadm to set the node.startup for existing records

iscsiadm -m node -o update -n node.startup -v manual
Comment 4 Daniel Berrange 2010-10-15 06:04:10 EDT
IMHO startup = manual should be the default here. Merely running iSCSI sendtargets should not be causing the host to automatically login to the targets forever after, unless the admin explicitly asked for that behaviour.
Comment 5 Mike Christie 2010-10-16 18:53:15 EDT
(In reply to comment #4)
> IMHO startup = manual should be the default here. Merely running iSCSI
> sendtargets should not be causing the host to automatically login to the
> targets forever after, unless the admin explicitly asked for that behaviour.

They do try to login forever though. They login for whatever your initial login retries and timeouts are set at.

Also normally users set things up on the target so only the targets that are accessible to the initiator are returned in sendtargets discovery. So every target returned during discovery is one they want to log into (this is why the default for startup is automatic).
Comment 6 Mike Christie 2010-10-16 18:58:11 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > IMHO startup = manual should be the default here. Merely running iSCSI
> > sendtargets should not be causing the host to automatically login to the
> > targets forever after, unless the admin explicitly asked for that behaviour.
> 
> They do try to login forever though. They login for whatever your initial login
> retries and timeouts are set at.
> 

Ignore that part of the comment above. I thought you meant something different.
Comment 7 Daniel Berrange 2010-11-12 11:28:39 EST
In a SOHO environment where people are using something like a Netgear/QNap NAS to provide iSCSI, it is far less likely that the target list will be zoned per client machine. In any case, I've added code to libvirt to force node.startup=manual everytime 'sendtargets' is run to work about this debatable behaviour.
Comment 8 Daniel Berrange 2010-11-12 11:29:09 EST
Patch series upstream

http://www.redhat.com/archives/libvir-list/2010-November/msg00545.html
Comment 9 Daniel Veillard 2011-01-23 23:25:10 EST
Should be available in F15, since we are not backporting to F14

Daniel