From 0cb89b73e9f1753c66779836bf15b98f00d8be6a Mon Sep 17 00:00:00 2001 From: Bowen Ding <6999708+dbw9580@users.noreply.github.com> Date: Tue, 22 Aug 2023 21:52:38 +0800 Subject: [PATCH] Fix multiple mount options not recognized ### What changes are proposed in this pull request? Fix multiple mount options specified by `-o` not recognized by Alluxio Fuse. The `-o` option can be specified multiple times, and each time it can take a comma separated list of `key=value` mount options. ### Why are the changes needed? Fuse mounting with `bin/alluxio-fuse mount hdfs://10.10.1.2:9000/ /work/alluxio_fuse -o kernel_cache -o attr_timeout=6000 -o entry_timeout=6000` errors with ``` Exception in thread "main" com.beust.jcommander.ParameterException: "-o": couldn't convert "kernel_cache,attr_timeout=6000,entry_timeout=6000" to a `key=value` pair because contains more than 1 `=` at alluxio.fuse.options.MountCliOptions$KvPairsConverter.convert(MountCliOptions.java:74) at alluxio.fuse.options.MountCliOptions$KvPairsConverter.convert(MountCliOptions.java:50) at com.beust.jcommander.JCommander.convertValue(JCommander.java:1333) at com.beust.jcommander.ParameterDescription.addValue(ParameterDescription.java:249) ``` The bash scripts concatenates the multiple occurrences of `-o` into a comma-separated list and passes it to the Java program. The PR does the other way around, preserving them and splitting the kv pair list in a `-o` option into multiple options. ### Does this PR introduce any user facing changes? No. pr-link: Alluxio/alluxio#18026 change-id: cid-d9b5dcf65ba3de1bd9324ed01f74944171d5ef30 --- dora/integration/fuse/bin/alluxio-fuse | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dora/integration/fuse/bin/alluxio-fuse b/dora/integration/fuse/bin/alluxio-fuse index 54ec59677ff4..79a61a78f272 100755 --- a/dora/integration/fuse/bin/alluxio-fuse +++ b/dora/integration/fuse/bin/alluxio-fuse @@ -186,7 +186,12 @@ launch_fuse_process() { while getopts "o:hf" opt > /dev/null 2>&1; do case "${opt}" in o) - mount_options+="${OPTARG}," + KV_PAIRS=(${OPTARG//,/ }) # split OPTARG by `,` into array + for pair in "${KV_PAIRS[@]}"; do + if [[ -n "$pair" ]]; then + mount_options+=" -o $pair" + fi + done ;; f) foreground='true' @@ -199,19 +204,14 @@ launch_fuse_process() { ;; esac done + readonly mount_options readonly foreground - + if fuse_mounted "${mount_point}"; then err "mount: ${mount_point} is already mounted" return 1 fi - mount_options="$(echo "${mount_options}" | sed -E 's/,*$//g')" # remove trailing comma - if [[ -n "${mount_options}" ]]; then - mount_options="-o ${mount_options}" - fi - readonly mount_options - if [[ "${foreground}" == 'true' ]]; then ALLUXIO_FUSE_JAVA_OPTS+=" -Dalluxio.logger.type=FUSE_LOGGER,Console" fi