Given iSCSI portal with multiple targets, where LUN is available only on one target, eg. targetd configured as follows:
{
"fabric_modules": [],
"storage_objects": [
{
"dev": "/var/lib/target/target1",
"name": "var-lib-target-target1",
"plugin": "fileio",
"size": 10485760,
"write_back": false,
"wwn": "bf00cf22-a354-4a72-b51b-2d29637c26b8"
}
],
"targets": [
{
"fabric": "iscsi",
"tpgs": [
{
"enable": true,
"luns": [
{
"index": 0,
"storage_object": "/backstores/fileio/var-lib-target-target1"
}
],
"node_acls": [
{
"mapped_luns": [
{
"index": 0,
"tpg_lun": 0,
"write_protect": false
}
],
"node_wwn": "iqn.2012-06.com.example:initiator0"
}
],
"portals": [
{
"ip_address": "192.168.0.100",
"iser": false,
"port": 3260
}
],
"tag": 1
}
],
"wwn": "iqn.2012-06.com.example:target0"
},
{
"fabric": "iscsi",
"tpgs": [
"luns": [],
"node_acls": [
"mapped_luns": [],
"node_wwn": "iqn.2012-06.com.example:initiator0"
}
],
"portals": [
{
"ip_address": "192.168.0.100",
"iser": false,
"port": 3260
}
],
"tag": 1
}
],
"wwn": "iqn.2012-06.com.example:target2"
}
]
}
When adding SR with wildcard Target IQN for multipathing support, operation fails with
The SR is not available [opterr=Error reporting error, unknown key Device not appeared yet]
and LUN offline or iscsi path down
due to incorrect iSCSI sessions handing.
Manually reconnecting (logging in) sessions results in operation success.
Following (completely incorrectly implemented) patch "fixes" this issue, but highly affects storage operations execution time:
diff --git a/drivers/LVHDoISCSISR.py b/drivers/LVHDoISCSISR.py
index 7562f36..ed4a439 100755
--- a/drivers/LVHDoISCSISR.py
+++ b/drivers/LVHDoISCSISR.py
@@ -145,6 +145,7 @@ class LVHDoISCSISR(LVHDSR.LVHDSR):
srcmd_copy.dconf['multiSession'] = IQNstring
util.SMlog("Setting targetlist: %s" % srcmd_copy.dconf['targetlist'])
self.iscsiSRs.append(BaseISCSI.BaseISCSISR(srcmd_copy, sr_uuid))
+ util.doexec(['iscsiadm', '-m', 'node', '--loginall=all'])
pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
if pbd <> None and not self.dconf.has_key('multiSession'):
dconf = self.session.xenapi.PBD.get_device_config(pbd)