Merge pull request #118624 from jsafrane/iscsi-dbus

iscsi: use dbus from the host
This commit is contained in:
Kubernetes Prow Robot 2023-06-13 05:00:09 -07:00 committed by GitHub
commit 232cdf9716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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