Skip to content

Commit

Permalink
Skip ssh for localhost
Browse files Browse the repository at this point in the history
### What changes are proposed in this pull request?

Skip ssh connection while running locally.

### Why are the changes needed?

I was trying to setup a one-node cluster with the latest version to do some simple tests. However, I encountered the following exception while executing `/bin/alluxio format`

```
$ ./bin/alluxio format
Executing the following command on all worker nodes and logging to /home/test/deploy/alluxio/logs/task.log: /home/test/deploy/alluxio/bin/alluxio formatWorker
Waiting for tasks to finish...
test@localhost's password:
test@localhost's password:
test@localhost's password:
Task on 'localhost' fails, exit code: 255
There are task failures, look at /home/test/deploy/alluxio/logs/task.log for details.
```

In the log, it has

```
[2023-03-24 17:12:20][localhost] Failed to add the host to the list of known hosts (/home/test/.ssh/known_hosts).
[2023-03-24 17:13:28][localhost] Permission denied, please try again.
[2023-03-24 17:13:29][localhost] Permission denied, please try again.
[2023-03-24 17:13:30][localhost] Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
```

However, in our cluster, we do not know the password of our accounts in a specific server. So I feel it's better to skip the "ssh" part for a local one-node cluster.

### Does this PR introduce any user facing changes?

NO.
			pr-link: #17167
			change-id: cid-0ade98d9517f269668a2f3cb384b8b079fa440be
  • Loading branch information
secfree committed Apr 12, 2023
1 parent 8cbcbcd commit 5f17042
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
10 changes: 10 additions & 0 deletions bin/alluxio-common.sh
Expand Up @@ -68,3 +68,13 @@ function get_ramdisk_array() {
done
IFS=$oldifs
}

# Compose the ssh command according to the hostname
function ssh_command() {
local host=$1
local command=""
if [[ $host != "localhost" && $host != "127.0.0.1" ]]; then
command="ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt ${host}"
fi
echo "${command}"
}
11 changes: 3 additions & 8 deletions bin/alluxio-masters.sh
Expand Up @@ -12,12 +12,7 @@

set -o pipefail

LAUNCHER=
# If debugging is enabled propagate that through to sub-shells
if [[ "$-" == *x* ]]; then
LAUNCHER="bash -x"
fi
BIN=$(cd "$( dirname "$( readlink "$0" || echo "$0" )" )"; pwd)
. $(dirname "$0")/alluxio-common.sh

USAGE="Usage: alluxio-masters.sh command..."

Expand Down Expand Up @@ -46,10 +41,10 @@ fi
for master in ${HOSTLIST[@]}; do
echo "[${master}] Connecting as ${USER}..." >> ${ALLUXIO_TASK_LOG}
if [[ ${HA_ENABLED} == "true" || ${N} -eq 0 ]]; then
nohup ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt ${master} ${LAUNCHER} \
nohup $(ssh_command ${master}) ${LAUNCHER} \
$"${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${master}] ${line}"; done >> ${ALLUXIO_TASK_LOG} &
else
nohup ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt ${master} ${LAUNCHER} \
nohup $(ssh_command ${master}) ${LAUNCHER} \
$"export ALLUXIO_MASTER_SECONDARY=true; ${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${master}] ${line}"; done >> ${ALLUXIO_TASK_LOG} &
fi
pids[${#pids[@]}]=$!
Expand Down
9 changes: 2 additions & 7 deletions bin/alluxio-workers.sh
Expand Up @@ -12,12 +12,7 @@

set -o pipefail

LAUNCHER=
# If debugging is enabled propagate that through to sub-shells
if [[ "$-" == *x* ]]; then
LAUNCHER="bash -x"
fi
BIN=$(cd "$( dirname "$( readlink "$0" || echo "$0" )" )"; pwd)
. $(dirname "$0")/alluxio-common.sh

USAGE="Usage: alluxio-workers.sh command..."

Expand All @@ -39,7 +34,7 @@ echo "Executing the following command on all worker nodes and logging to ${ALLUX

for worker in ${HOSTLIST[@]}; do
echo "[${worker}] Connecting as ${USER}..." >> ${ALLUXIO_TASK_LOG}
nohup ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt ${worker} ${LAUNCHER} \
nohup $(ssh_command ${worker}) ${LAUNCHER} \
$"${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${worker}] ${line}"; done >> ${ALLUXIO_TASK_LOG} &
pids[${#pids[@]}]=$!
done
Expand Down

0 comments on commit 5f17042

Please sign in to comment.