Hello,
I am currently working on integrating RStudio Server as an interactive app within Open OnDemand on a CentOS 7.9 machine. The machine connects to my cluster via host-based authentication and I have successfully set up similar interactive apps like Jupyter Notebook.
I encountered challenges due to the default behavior of RStudio Server, which runs on a specific port and fails if a session is initiated on a different port. To address this, I attempted to follow various examples, particularly those involving building a custom Singularity image. Despite these efforts, the integration has not yet been successful.
Here is a brief overview of my progress and issues:
Setup Steps Completed:
- Copied RStudio App: Successfully copied and configured to send RStudio Server requests to the compute node.
- Software Requirements: Confirmed the presence of required software:
R
:/usr/bin/R
rstudio-server
: Successfully installed but currently inactive.singularity
:/usr/local/bin/singularity
Setup Steps Attempted:
The steps to be complete were unclear for me, since the default behavior for rstudio-server is to run on a specific unique port and the service would fail if a session is made with a different port. Then I’ve attempted to follow some examples, specially having to build the image.
Current Challenge:
The primary challenge is running RStudio Server within a Singularity container on the compute node which uses Ubuntu. I built a custom Singularity image successfully, but the integration fails when launching from the Open OnDemand UI.
Singularity.def File:
Bootstrap: docker
From: ubuntu:22.04
%labels
Maintainer oodadmin
Version 0.1
%help
This will run RStudio Server which must be mounted with dependencies into the container.
%post
export DEBIAN_FRONTEND=noninteractive
...
apt-get update && apt-get install -y \
r-base \
r-base-dev \
r-cran-foreign \
r-cran-ggplot2 \
wget \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
tzdata \
dpkg-sig \
gnupg \
netcat \
sudo
useradd -m -s /bin/bash rstudio
mkdir -p /root/.gnupg
# Import RStudio public key
cat << 'EOF_KEY' | gpg --import
-----BEGIN PGP PUBLIC KEY BLOCK-----
[# (Key content)](https://cloud.rstudio.com/code-signing/)
-----END PGP PUBLIC KEY BLOCK-----
EOF_KEY
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb
dpkg -i libssl1.1_1.1.1f-1ubuntu2.22_amd64.deb
RSTUDIO_VERSION="2024.04.1-748"
RSTUDIO_DEB="rstudio-server-${RSTUDIO_VERSION}-amd64.deb"
wget https://download2.rstudio.org/server/jammy/amd64/${RSTUDIO_DEB}
apt install -y ./${RSTUDIO_DEB}
mkdir -p /etc/rstudio
cat << 'EOF_CONF' > /etc/rstudio/rserver.conf
server-user=rstudio
auth-none=1
server-project-sharing=0
auth-pam-sessions-enabled=0
EOF_CONF
apt-get clean
rm -rf /var/lib/apt/lists/*
%environment
export PATH=/usr/lib/rstudio-server/bin:$PATH
%apprun rserver
exec rserver "${@}"
%runscript
exec rserver "${@}"
Script.sh.erb File Modifications:
#!/usr/bin/env bash
set -x
echo "Script starting..."
echo "Waiting for RStudio Server to open port ${port}..."
echo "TIMING - Starting wait at: $(date)"
setup_env () {
export RSTUDIO_SERVER_IMAGE="/home/aymane/Scripts/RStudio/rstudio-server.sif"
export SINGULARITY_BINDPATH="/etc,/media,/mnt,/opt,/srv,/usr,/var"
export PATH="$PATH:/usr/lib/rstudio-server/bin"
}
setup_env
export TMPDIR="${PWD}/rstudio-server-tmp"
mkdir -p $TMPDIR/var/lib/rstudio-server
mkdir -p $TMPDIR/var/run/rstudio-server
cat /proc/sys/kernel/random/uuid > "$TMPDIR/var/run/rstudio-server/secure-cookie-key"
chmod 0600 "$TMPDIR/var/run/rstudio-server/secure-cookie-key"
export RSTUDIO_DB_FILE="$TMPDIR/var/lib/rstudio-server/rstudio-os.sqlite"
touch $RSTUDIO_DB_FILE
chmod 0600 $RSTUDIO_DB_FILE
echo "Starting up rserver..."
singularity exec --bind $TMPDIR/var/lib/rstudio-server:/var/lib/rstudio-server \
--bind $TMPDIR/var/run/rstudio-server:/var/run/rstudio-server \
--home /home/oodadmin:/home/oodadmin \
$RSTUDIO_SERVER_IMAGE \
/usr/lib/rstudio-server/bin/rserver \
--auth-none 1 \
--www-port=${port} \
--secure-cookie-key-file=/var/run/rstudio-server/secure-cookie-key \
--database-config-file=/var/lib/rstudio-server/rstudio-os.sqlite &
sleep 5
echo 'Singularity has exited...'
echo "Waiting for RStudio Server to open port ${port}..."
timeout 60 sh -c 'until nc -z localhost ${port}; do sleep 1; done'
if ! nc -z localhost ${port}; then
echo "Timed out waiting for RStudio Server to open port ${port}!"
echo "Capturing log files for debugging:"
if [ -f "${TMPDIR}/rsession.log" ]; then
echo "Content of rsession.log:"
cat "${TMPDIR}/rsession.log"
else
echo "rsession.log not found."
fi
if [ -f "${HOME}/.local/share/rstudio/log/rserver.log" ]; then
echo "Content of rserver.log:"
cat "${HOME}/.local/share/rstudio/log/rserver.log"
fi
exit 1
else
echo "RStudio Server is running on port ${port}"
fi
Issue Faced:
When launching RStudio Server from the UI, it fails with the following error:
/var/spool/slurm/d/job310697/slurm_script: line 3: module: command not found
Script starting...
Waiting for RStudio Server to open port 55677...
...
Timed out waiting for RStudio Server to open port 55677!
...
Content of rserver.log:
ERROR Attempt to run server as user 'rstudio-server' (uid 997) from account 'oodadmin' (uid 1406410999) without privilege...
Log File Content:
2024-06-05T07:18:12.108552Z [rserver] ERROR Attempt to run server as user 'rstudio-server' (uid 997) from account 'oodadmin' (uid 1406410999) without privilege, which is required to run as a different uid; LOGGED FROM: virtual rstudio::core::ProgramStatus rstudio::server::Options::read(int, char* const*, std::ostream&) src/cpp/server/ServerOptions.cpp:327
...
ERROR system error 1 (Operation not permitted) [path: /var/lib/rstudio-server/rstudio-os.sqlite]; OCCURRED AT rstudio::core::Error rstudio::core::{anonymous}::changeFileModeImpl(const string&, mode_t) src/cpp/shared_core/FilePath.cpp:318
Request for Help:
- How can I properly run the RStudio Server as a non-root user within the Singularity container?
- Are there additional configurations required to grant necessary privileges?
- Any insights on resolving the “Operation not permitted” error for the SQLite database file?
Thank you in advance for your help and suggestions!