iscsi: use dbus from the host

When running iscsi test, use dbus socket from the host. targetcli uses the
socket for synchronization.

Recent Fedoras can run dbus only via systemd, which is cumbersome here.
This commit is contained in:
Jan Safranek 2023-06-12 15:43:11 +02:00
parent 18d05b646d
commit 75cf25c0e7
3 changed files with 10 additions and 16 deletions

View File

@ -347,6 +347,8 @@ func newISCSIServer(ctx context.Context, cs clientset.Interface, namespace strin
"/sys/kernel": "/sys/kernel",
// iSCSI source "block devices" must be available on the host
"/srv/iscsi": "/srv/iscsi",
// targetcli uses dbus
"/run/dbus": "/run/dbus",
},
ServerReadyMessage: "iscsi target started",
ServerHostNetwork: true,

View File

@ -1 +1 @@
2.5
2.6

View File

@ -21,20 +21,12 @@
# Kubernetes must provide unique name.
IQN=$1
# targetcli synchronizes over dbus, however it does not work in
# containers. Use flock instead
LOCK=/srv/iscsi/targetcli.lock
function start()
{
# targetcli need dbus. It may not run on the host, so start a private one
mkdir /run/dbus
dbus-daemon --system
# Create new IQN (iSCSI Qualified Name)
flock $LOCK targetcli /iscsi create "$IQN"
targetcli /iscsi create "$IQN"
# Run it in demo mode, i.e. no authentication
flock $LOCK targetcli /iscsi/"$IQN"/tpg1 set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
targetcli /iscsi/"$IQN"/tpg1 set attribute authentication=0 demo_mode_write_protect=0 generate_node_acls=1 cache_dynamic_acls=1
# Create unique "block volume" (i.e. flat file) on the *host*.
# Having it in the container confuses kernel from some reason
@ -44,8 +36,8 @@ function start()
cp /block /srv/iscsi/"$IQN"
# Make the block volume available through our IQN as LUN 0
flock $LOCK targetcli /backstores/fileio create block-"$IQN" /srv/iscsi/"$IQN"
flock $LOCK targetcli /iscsi/"$IQN"/tpg1/luns create /backstores/fileio/block-"$IQN"
targetcli /backstores/fileio create block-"$IQN" /srv/iscsi/"$IQN"
targetcli /iscsi/"$IQN"/tpg1/luns create /backstores/fileio/block-"$IQN"
echo "iscsi target started"
}
@ -54,10 +46,10 @@ function stop()
{
echo "stopping iscsi target"
# Remove IQN
flock $LOCK targetcli /iscsi/"$IQN"/tpg1/luns/ delete 0
flock $LOCK targetcli /iscsi delete "$IQN"
targetcli /iscsi/"$IQN"/tpg1/luns/ delete 0
targetcli /iscsi delete "$IQN"
# Remove block device mapping
flock $LOCK targetcli /backstores/fileio delete block-"$IQN"
targetcli /backstores/fileio delete block-"$IQN"
/bin/rm -f /srv/iscsi/"$IQN"
echo "iscsi target stopped"
exit 0