From d78aee9157c52c0ff2d0df52d0eb11f613a52a09 Mon Sep 17 00:00:00 2001 From: Henrik Bengtsson Date: Mon, 9 Oct 2023 14:17:19 -0700 Subject: [PATCH 1/3] BUG FIX: `rsc start` and `rsc status` would stall if the host where the RStudio Server was last running is not responding to SSH. Now it times out. --- NEWS.md | 9 +++++++++ bin/rsc | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 225ada4..1415a24 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +## Version (development version) + +### Bug Fixes + + * `rsc start` and `rsc status` would stall if the RStudio Server was + previously running on another host and that host no longer responds + on SSH. Now it will timeout with an informative error message. + + ## Version 0.13.7 [2023-10-04] ### Miscellaneous diff --git a/bin/rsc b/bin/rsc index 19ec83f..6f27429 100755 --- a/bin/rsc +++ b/bin/rsc @@ -63,7 +63,7 @@ ### rsc config --full ### rsc log ### -### Version: 0.13.7 +### Version: 0.13.7-9001 ### Copyright: Henrik Bengtsson (2022-2023) and Harry Putnam (2022) ### License: ISC @@ -445,6 +445,12 @@ function make_rserver_conf { # ------------------------------------------------------------------------- # Misc. utilities # ------------------------------------------------------------------------- +function ssh_timeout { + local timeout=${RSC_SSH_TIMEOUT:-15} + assert_integer "${timeout}" + echo "${timeout}" +} + function parse_revtunnel { local spec local hostname @@ -469,6 +475,7 @@ function check_pid { local hostname local pid_exists local asterisk + local timeout ## If 'pid' is assigned an empty value, then it becomes pid=0, ## because we declared it as an integer above. @@ -486,9 +493,9 @@ function check_pid { mdebug "- Checking /proc/${pid} on current machine (${hostname})" [[ -d "/proc/${pid}" ]] && pid_exists=true elif ${ssh}; then - mdebug "- Checking /proc/${pid} on ${hostname} over SSH" + mdebug "- Checking /proc/${pid} on ${hostname} over SSH ($(ssh_timeout)-second timeout)" #shellcheck disable=SC2029 - res=$(ssh "${hostname}" "[[ -d '/proc/${pid}' ]] && echo true || echo false") || error "Failed to check process PID ${pid} on ${hostname} over SSH" + res=$(ssh -o ConnectTimeout="$(ssh_timeout)" "${hostname}" "[[ -d '/proc/${pid}' ]] && echo true || echo false" 2>&1) || error "Failed to check process PID ${pid} on ${hostname} over SSH. Reason was: ${res}" [[ "${res}" == "true" ]] && pid_exists=true else mdebug "- Skipping check of /proc/${pid} on ${hostname}, because --no-ssh" @@ -1707,12 +1714,12 @@ elif [[ "${action}" == "start" ]]; then pid_file=$(ssh_revtunnel_pid_file) if $dryrun; then - echo "DRYRUN: ssh -N -R \"${rev_spec}\" \"${rev_hostname}\"" + echo "DRYRUN: ssh -o ConnectTimeout="$(ssh_timeout)" -N -R \"${rev_spec}\" \"${rev_hostname}\"" sleep 60 & else - mdebug "ssh -N -R \"${rev_spec}\" \"${rev_hostname}\"" + mdebug "ssh -o ConnectTimeout="$(ssh_timeout)" -N -R \"${rev_spec}\" \"${rev_hostname}\"" printf "%s\n%s\n" "${rev_hostname}" "${rev_port}" > "$(ssh_revtunnel_spec_file)" - ssh -N -R "${rev_spec}" "${rev_hostname}" & + ssh -o ConnectTimeout="$(ssh_timeout)" -N -R "${rev_spec}" "${rev_hostname}" & fi ssh_pid=$! echo "${ssh_pid}" > "${pid_file}" From 8ef0ec6d3c7bb27f112aee6b84305c4804acd7b5 Mon Sep 17 00:00:00 2001 From: Henrik Bengtsson Date: Mon, 9 Oct 2023 14:25:15 -0700 Subject: [PATCH 2/3] Fix ShellCheck issues just introduced --- bin/rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/rsc b/bin/rsc index 6f27429..4736841 100755 --- a/bin/rsc +++ b/bin/rsc @@ -1714,10 +1714,10 @@ elif [[ "${action}" == "start" ]]; then pid_file=$(ssh_revtunnel_pid_file) if $dryrun; then - echo "DRYRUN: ssh -o ConnectTimeout="$(ssh_timeout)" -N -R \"${rev_spec}\" \"${rev_hostname}\"" + echo "DRYRUN: ssh -o ConnectTimeout=\"$(ssh_timeout)\" -N -R \"${rev_spec}\" \"${rev_hostname}\"" sleep 60 & else - mdebug "ssh -o ConnectTimeout="$(ssh_timeout)" -N -R \"${rev_spec}\" \"${rev_hostname}\"" + mdebug "ssh -o ConnectTimeout=\"$(ssh_timeout)\" -N -R \"${rev_spec}\" \"${rev_hostname}\"" printf "%s\n%s\n" "${rev_hostname}" "${rev_port}" > "$(ssh_revtunnel_spec_file)" ssh -o ConnectTimeout="$(ssh_timeout)" -N -R "${rev_spec}" "${rev_hostname}" & fi From 763abbcf2ab41fef3b46a2e32cc43e24879a50a9 Mon Sep 17 00:00:00 2001 From: Henrik Bengtsson Date: Mon, 9 Oct 2023 14:31:06 -0700 Subject: [PATCH 3/3] rsc 0.13.8 --- Makefile | 2 ++ NEWS.md | 2 +- README.md | 10 +++++----- bin/rsc | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d3b1f46..1b52fb5 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +check: shellcheck spelling + shellcheck: (cd bin; \ shellcheck --shell=bash --external-sources -- incl/*.sh; \ diff --git a/NEWS.md b/NEWS.md index 1415a24..ba00165 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -## Version (development version) +## Version 0.13.8 [2023-10-09] ### Bug Fixes diff --git a/README.md b/README.md index c809dcb..151c214 100644 --- a/README.md +++ b/README.md @@ -333,12 +333,12 @@ As before, the RStudio Server is available at ```sh $ cd /path/to/software -$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.13.7.tar.gz -$ tar xf 0.13.7.tar.gz -$ PATH=/path/to/softwarerstudio-server-controller-0.13.7/bin:$PATH +$ curl -L -O https://github.com/UCSF-CBI/rstudio-server-controller/archive/refs/tags/0.13.8.tar.gz +$ tar xf 0.13.8.tar.gz +$ PATH=/path/to/softwarerstudio-server-controller-0.13.8/bin:$PATH $ export PATH $ rsc --version -0.13.7 +0.13.8 ``` To verify that the tool can find R and the RStudio Server executables, @@ -346,7 +346,7 @@ call: ```sh $ rsc --version --full -rsc: 0.13.7 +rsc: 0.13.8 RStudio Server: 2023.06.2+561 (Mountain Hydrangea) for Linux [/path/to/rstudio-server/bin/rstudio-server] R: 4.3.1 (2023-06-16) -- "Shortstop Beagle" [/path/to/R/bin/R] ``` diff --git a/bin/rsc b/bin/rsc index 4736841..6de86cc 100755 --- a/bin/rsc +++ b/bin/rsc @@ -63,7 +63,7 @@ ### rsc config --full ### rsc log ### -### Version: 0.13.7-9001 +### Version: 0.13.8 ### Copyright: Henrik Bengtsson (2022-2023) and Harry Putnam (2022) ### License: ISC