From 75cf25c0e7f40826c02e1f9061aeb5cc3f5f09d3 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 12 Jun 2023 15:43:11 +0200 Subject: [PATCH] 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. --- test/e2e/storage/drivers/in_tree.go | 2 ++ test/images/volume/iscsi/VERSION | 2 +- test/images/volume/iscsi/run_iscsi_target.sh | 22 +++++++------------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/test/e2e/storage/drivers/in_tree.go b/test/e2e/storage/drivers/in_tree.go index 70a278f4a10..75cd61c2163 100644 --- a/test/e2e/storage/drivers/in_tree.go +++ b/test/e2e/storage/drivers/in_tree.go @@ -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, diff --git a/test/images/volume/iscsi/VERSION b/test/images/volume/iscsi/VERSION index 95e3ba81920..5154b3f68e9 100644 --- a/test/images/volume/iscsi/VERSION +++ b/test/images/volume/iscsi/VERSION @@ -1 +1 @@ -2.5 +2.6 diff --git a/test/images/volume/iscsi/run_iscsi_target.sh b/test/images/volume/iscsi/run_iscsi_target.sh index 034beb44277..b27a419e118 100755 --- a/test/images/volume/iscsi/run_iscsi_target.sh +++ b/test/images/volume/iscsi/run_iscsi_target.sh @@ -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