Skip to content

Commit

Permalink
iscsi: use dbus from the host
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsafrane committed Jun 12, 2023
1 parent 18d05b6 commit 75cf25c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 2 additions & 0 deletions test/e2e/storage/drivers/in_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/images/volume/iscsi/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5
2.6
22 changes: 7 additions & 15 deletions test/images/volume/iscsi/run_iscsi_target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
Expand All @@ -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
Expand Down

0 comments on commit 75cf25c

Please sign in to comment.