Blame SOURCES/bz1692413-1-iSCSITarget-create-iqn-when-it-doesnt-exist.patch

b4b3ce
From 9273b83edf6ee72a59511f307e168813ca3d31fd Mon Sep 17 00:00:00 2001
b4b3ce
From: colttt <shadow_7@gmx.net>
b4b3ce
Date: Fri, 12 Oct 2018 15:29:48 +0200
b4b3ce
Subject: [PATCH] possible fix for #1026
b4b3ce
b4b3ce
add an if-condition and remove an useless 'targetcli create'
b4b3ce
---
b4b3ce
 heartbeat/iSCSITarget.in | 6 +++---
b4b3ce
 1 file changed, 3 insertions(+), 3 deletions(-)
b4b3ce
b4b3ce
diff --git a/heartbeat/iSCSITarget.in b/heartbeat/iSCSITarget.in
b4b3ce
index e49a79016..9128fdc55 100644
b4b3ce
--- a/heartbeat/iSCSITarget.in
b4b3ce
+++ b/heartbeat/iSCSITarget.in
b4b3ce
@@ -340,13 +340,13 @@ iSCSITarget_start() {
b4b3ce
 		ocf_take_lock $TARGETLOCKFILE
b4b3ce
 		ocf_release_lock_on_exit $TARGETLOCKFILE
b4b3ce
 		ocf_run targetcli /iscsi set global auto_add_default_portal=false || exit $OCF_ERR_GENERIC
b4b3ce
-		ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
b4b3ce
+		if ! [ -d /sys/kernel/config/target/iscsi/${OCF_RESKEY_iqn} ] ; then
b4b3ce
+			ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
b4b3ce
+		fi
b4b3ce
 		for portal in ${OCF_RESKEY_portals}; do
b4b3ce
 			if [ $portal != ${OCF_RESKEY_portals_default} ] ; then
b4b3ce
 				IFS=':' read -a sep_portal <<< "$portal"
b4b3ce
 				ocf_run targetcli /iscsi/${OCF_RESKEY_iqn}/tpg1/portals create "${sep_portal[0]}" "${sep_portal[1]}" || exit $OCF_ERR_GENERIC
b4b3ce
-			else
b4b3ce
-				ocf_run targetcli /iscsi create ${OCF_RESKEY_iqn} || exit $OCF_ERR_GENERIC
b4b3ce
 			fi
b4b3ce
 		done
b4b3ce
 		# in lio, we can set target parameters by manipulating