Commit 1c2d994c authored by Mike Hibler's avatar Mike Hibler

Make sure iscsid picks up change of initiator name.

Otherwise you get a lot of this action:

WARNING: 10.254.254.203 (iqn.1993-08.org.debian:01:5ad48b44316d): session reinstatement from different address 10.254.254.201

The issue was that we would restart iscsid after changing the name, but if the
iSCSI sessions were already open, the name change would not immediately take
effect (til next reboot).

This will happen if the open-iscsi and/or iscsid service is started at boot time
prior to the Emulab blockstore config running. We explicitly turned these services
off in Ubuntu 14, but not in 16 and above cuz that would involve interaction with
systemd and some of us don't speak systemd. Anyway, this will work even if the
services are enabled at boot.
parent e351dc97
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2018 University of Utah and the Flux Group.
# Copyright (c) 2013-2019 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -769,12 +769,38 @@ sub set_iname($$)
print FD "InitiatorName=$iname\n";
close(FD);
# restart iscsid
if (mysystem("service open-iscsi restart $redir")) {
warn("*** storage: could not restart iscsid!\n");
return 0;
#
# XXX iscsid might already be running with the wrong initiator name.
# So, we need to logout of all sessions:
# iscsiadm -m node -U all
# restart services:
# systemctl restart iscsid open-iscsi
# and login again:
# iscsiadm -m node -L all
#
# XXX we only do this for Ubuntu 16 and beyond where we know that iscsid
# is enabled by default. Conveniently, we can use the existence of systemctl
# as an indicator. Basically, we don't care about Ubuntu 14 and before
# except to not break it.
#
if (-x "/bin/systemctl") {
my $nsess = `$ISCSI -m session 2>/dev/null | grep -c ^`;
chomp($nsess);
if ($nsess != 0 && mysystem("$ISCSI -m node -U all $redir")) {
warn("*** storage: could not logout of iscsi sessions!\n");
}
if (mysystem("/bin/systemctl restart iscsid open-iscsi $redir")) {
warn("*** storage: could not restart iscsi daemons!\n");
}
if ($nsess != 0 && mysystem("$ISCSI -m node -L all $redir")) {
warn("*** storage: could not login to iscsi sessions!\n");
}
} else {
# restart iscsid
if (mysystem("service open-iscsi restart $redir")) {
warn("*** storage: could not restart iscsid!\n");
}
}
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment