dynamic host volumes: plugin spec tweaks (#24848)

* prefix plugin env vars with DHV_
* add env: DHV_VOLUME_ID, DHV_PLUGIN_DIR
* 5s timeout on fingerprint calls
This commit is contained in:
Daniel Bennett
2025-01-13 15:18:10 -05:00
committed by GitHub
parent 203a6533bb
commit 985eb53c65
8 changed files with 144 additions and 88 deletions

View File

@@ -42,26 +42,37 @@ plugin="$1"
op="$2"
alloc_mounts="${3:-/tmp}"
uuid="${4:-74564d17-ce50-0bc1-48e5-6feaa41ede48}"
node_id='0b62d807-6101-a80f-374d-e1c430abbf47'
plugin_dir="$(dirname "$plugin")"
case $op in
fingerprint)
args='fingerprint'
export DHV_OPERATION='fingerprint'
;;
create)
args="create $alloc_mounts/$uuid"
export HOST_PATH="$alloc_mounts/$uuid"
export VOLUME_NAME=test
export NODE_ID=0b62d807-6101-a80f-374d-e1c430abbf47
export CAPACITY_MAX_BYTES=50000000 # 50mb
export CAPACITY_MIN_BYTES=50000000 # 50mb
export PARAMETERS='{"a": "ayy"}'
export DHV_OPERATION='create'
export DHV_HOST_PATH="$alloc_mounts/$uuid"
export DHV_VOLUME_NAME=test
export DHV_VOLUME_ID="$uuid"
export DHV_NODE_ID="$node_id"
export DHV_CAPACITY_MAX_BYTES=50000000 # 50mb
export DHV_CAPACITY_MIN_BYTES=50000000 # 50mb
export DHV_PARAMETERS='{"a": "ayy"}'
export DHV_PLUGIN_DIR="$plugin_dir"
;;
delete)
args="delete $alloc_mounts/$uuid"
export HOST_PATH="$alloc_mounts/$uuid"
export PARAMETERS='{"a": "ayy"}'
export DHV_OPERATION='delete'
export DHV_HOST_PATH="$alloc_mounts/$uuid"
export DHV_NODE_ID="$node_id"
export DHV_VOLUME_NAME=test
export DHV_VOLUME_ID="$uuid"
export DHV_PARAMETERS='{"a": "ayy"}'
export DHV_PLUGIN_DIR="$plugin_dir"
;;
*)
@@ -69,6 +80,5 @@ case $op in
;;
esac
export OPERATION="$op"
set -x
eval "$plugin $args"

View File

@@ -120,7 +120,7 @@ delete_volume() {
case "$1" in
"create")
create_volume "$host_path" "$CAPACITY_MIN_BYTES"
create_volume "$host_path" "$DHV_CAPACITY_MIN_BYTES"
# output what Nomad expects
bytes="$(st "$host_path".$ext)"
printf '{"path": "%s", "bytes": %s}' "$host_path" "$bytes"