Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat:support dynamic mount of subpath format JuiceFS mount-points #4241

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions addons/dynamic-mount/juicefs/docker/mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,37 @@ if [[ $# -ne 4 ]]; then
exit 1
fi

mount_src=$1 # e.g. juicefs://mybucket
mount_src=$1 # e.g. juicefs://volume-name/subpath
mount_target=$2 # e.g. /runtime-mnt/thin/default/thin-demo/thin-fuse/mybucket
fs_type=$3
mount_opt_file=$4 # e.g. /etc/fluid/mount-opts/mybucket.opts (mount options in json format)

filesystem_name=${mount_src#juicefs://}
# Check if the mount_src starts with juicefs://
if [[ "$mount_src" == juicefs://* ]]; then
juicefs_volume_path=${mount_src#juicefs://}
else
echo "Error: mount_src does not start with juicefs://"
exit 1
fi

if [[ "$juicefs_volume_path" == *"/"* ]]; then
volume_name="${juicefs_volume_path%%/*}"
volume_subpath="${juicefs_volume_path#*/}"
else
volume_name=$juicefs_volume_path
fi

token_file=$(cat ${mount_opt_file} | jq -r '.["token"]')
access_key_file=$(cat ${mount_opt_file} | jq -r '.["access-key"]')
secret_key_file=$(cat ${mount_opt_file} | jq -r '.["secret-key"]')
bucket=$(cat ${mount_opt_file} | jq -r '.["bucket"]')

juicefs auth $filesystem_name --token `cat $token_file` --access-key `cat $access_key_file` --secret-key `cat $secret_key_file` --bucket "$bucket"
juicefs auth $volume_name --token `cat $token_file` --access-key `cat $access_key_file` --secret-key `cat $secret_key_file` --bucket "$bucket"

exec juicefs mount -f $filesystem_name $mount_target
if [[ -z "$volume_subpath" ]]; then
# e.g. juicefs://volume-name/ || juicefs://volume-name
exec juicefs mount -f $volume_name $mount_target
else
# e.g. juicefs://volume-name/subpath-1 || juicefs://volume-name/subpath-1/subpath-2/.../
exec juicefs mount -f $volume_name $mount_target --subdir="/"$volume_subpath
fi
Loading