PKUHPC / OpenSCOW

Super Computing On Web
https://www.pkuscow.com/
Mulan Permissive Software License, Version 2
215 stars 45 forks source link

创建R应用报错 #1078

Open zhengkang2020 opened 10 months ago

zhengkang2020 commented 10 months ago

按文档https://icode.pku.edu.cn/SCOW/docs/deploy/config/portal/apps/apps/rstudio 配置 RStudio Server 1.4.1103及之后版本源码方式的RStudio Server后,创建R应用报错 image

下面是输出日志slurm-13.out

+ echo 'Starting up rserver...'
Starting up rserver...
+ singularity run -B /tmp:/tmp,/data:/data /data/software/rstudio-server/rstudio.sif /usr/lib/rstudio-server/bin/rserver --www-port 37943 --auth-none 1 --auth-pam-helper-path /data/software/rstudio-server/auth --auth-encrypt-password 0 --rsession-path /data/home/zhengkangzhang/scow/appData/RStudio-20240123-101708/rsession.sh --server-data-dir /tmp/tmp.aai6St5wgV --server-user zhengkangzhang --secure-cookie-key-file /tmp/tmp.aai6St5wgV/rstudio-server/secure-cookie-key --database-config-file /data/home/zhengkangzhang/scow/appData/RStudio-20240123-101708/database.conf --rsession-which-r /data/software/R/R-4.2.3/bin/R

before.sh

export PROXY_BASE_PATH=/api/proxy/hpc01/relative
export r_version=R-4.2.3
export PORT=$(get_port)
export PASSWORD=$(get_password 12)
export SLURM_COMPUTE_NODE_HOSTNAME=$(hostname)
export APPURI="${PROXY_BASE_PATH}/${SLURM_COMPUTE_NODE_HOSTNAME}/${PORT}/"
export USER=${USER}
export SINGULARITY_VERSION="singularity/3.9.2"
echo -e "{\"HOST\":\"$HOST\",\"PORT\":$PORT,\"PASSWORD\":\"$PASSWORD\",\"USER\":\"$USER\",\"APPURI\":\"$APPURI\"}" >$SERVER_SESSION_INFO
zhengkang2020 commented 9 months ago

/data/software/rstudio-server目录新建auth文件后,报错改变

auth

#!/usr/bin/env bash

#echo "ABC" >> ~/b.txt
#echo $@ >> ~/b.txt
#echo ${RSTUDIO_PASSWORD} >> ~/b.txt
#echo ${PASSWORD} >> ~/b.txt

# Confirm username is supplied
#if [[ $# -ne 1 ]]; then
#  echo "Usage: auth USERNAME"
#  exit 1
#fi
USERNAME="${1}"
#echo "DD" >> ~/b.txt

# Confirm password environment variable exists
if [[ -z ${RSTUDIO_PASSWORD} ]]; then
  echo "The environment variable RSTUDIO_PASSWORD is not set"
  exit 1
fi
#echo "EE" >> ~/b.txt
# Read in the password from user
read -s -p "Password: " PASSWORD
echo ""

if [[ ${USERNAME} == ${USER} && ${PASSWORD} == ${RSTUDIO_PASSWORD} ]]; then
  echo "Successful authentication"
  exit 0
else
  echo "Invalid authentication"
  exit 1
fi

image

rsession.log

Launching rsession...
+ exec /usr/lib/rstudio-server/bin/rsession --r-libs-user '' -u XXXX --session-use-secure-cookies 0 --session-root-path / --session-same-site 0 --session-use-file-storage 1 --launcher-token 57050296 --r-restore-workspace 2 --r-run-rprofile 2
/usr/lib/rstudio-server/bin/rsession: error while loading shared libraries: libgfortran.so.5: cannot open shared object file: No such file or directory
Launching rsession...

通过Singularity 进入镜像正常

[root@hpc-node1 rstudio-server]# singularity shell rstudio.sif
Singularity> ls /usr/lib/rstudio-server/bin/
crash-handler-proxy  crashpad_handler  crashpad_http_upload  postback  quarto  r-ldpath  rpostback  rserver  rserver-pam  rserver-url  rsession  rstudio-server
zhengkang2020 commented 8 months ago

任何人有相关进展吗?

wyzhh commented 5 months ago

请问问题解决了吗

zhengkang2020 commented 5 months ago

没有

zhengkang2020 commented 2 months ago

重新使用以下环境编译以后还是不行,报错404。 go:1.23.1 R:4.2.3 rstudio-server:2024.04.0-768 Dockerfile镜像:rhel9 系统:RockyLinux 9.4 scow:v1.6.3

连接的url好像有问题?日志中没有报错,看上去正常。 https://test-hpc.xxxx.com/auth-sign-in?appUri=appUri&error=2

zhengkang2020 commented 1 month ago

通过IP:port的方式能正常使用,通过已创建应用中的连接链接类使用这种https://XXXX/auth-sign-in?appUri=%2Fapi%2Fproxy%2Fhpc01%2Frelative%2Ftest-node2%2F39867%2F&error=1 是不是这个url有问题?

下面是rstudio.yml的配置文件。

# 这个应用的ID
id: rstudio

# 这个应用的名字
name: RStudio

# 指定应用类型为web
type: web

# Web应用的配置
web:
  # 指定反向代理类型
  proxyType: relative
  # 准备脚本
  beforeScript: |
    export PORT=$(get_port)
    export PASSWORD=$(get_password 12)
    export SLURM_COMPUTE_NODE_HOSTNAME=$(hostname)
    export APPURI="${PROXY_BASE_PATH}/${SLURM_COMPUTE_NODE_HOSTNAME}/${PORT}/"
    export USER=${USER}
    export SINGULARITY_VERSION="singularity/4.2.0"

  # 运行任务的脚本。可以使用准备脚本定义的变量
  script: |
    setup_env () {
        # Additional environment which could be moved into a module
        export RSTUDIO_PASSWORD=${PASSWORD}
        # Change these to suit
        export RSTUDIO_SERVER_IMAGE="/data/software/rstudio-server/rstudio.sif"

        # 容器中rstudio的路径
        export RSTUDIO_HOME=/usr/lib/rstudio-server
        export RSTUDIO_BIN_PATH=${RSTUDIO_HOME}/bin
        export RSTUDIO_RSERVER=${RSTUDIO_BIN_PATH}/rserver
        export RSTUDIO_RSESSION=${RSTUDIO_BIN_PATH}/rsession

        export RSTUDIO_AUTH="/data/software/rstudio-server/auth"
        export RSESSION_WRAPPER_FILE="${PWD}/rsession.sh"
        export DB_CONF_FILE="${PWD}/database.conf"
        export WHICHR=/data/software/R/${r_version}/bin/R
    }
    setup_env
    module switch ${SINGULARITY_VERSION}
    (
    umask 077
    sed 's/^ \{2\}//' > "${RSESSION_WRAPPER_FILE}" << EOL
    #!/usr/bin/env bash
    # Log all output from this script
    export RSESSION_LOG_FILE="${PWD}/rsession.log"
    exec &>>"\${RSESSION_LOG_FILE}"
    # Launch the original command
    echo "Launching rsession..."
    set -x
    exec ${RSTUDIO_RSESSION} --r-libs-user "${R_LIBS_USER}" "\${@}"
    EOL
    )

    chmod 700 "${RSESSION_WRAPPER_FILE}"
    cd "${HOME}"
    export TMPDIR="$(mktemp -d)"
    mkdir -p "$TMPDIR/rstudio-server"
    python -c 'from uuid import uuid4; print(uuid4())' > "$TMPDIR/rstudio-server/secure-cookie-key"
    chmod 0600 "$TMPDIR/rstudio-server/secure-cookie-key"

    (
    umask 177
    cat > "${DB_CONF_FILE}" << EOL
    provider=sqlite
    directory=${HOME}/.local/share/rstudio/database
    EOL
    )

    set -x
    # Launch the RStudio Server
    echo "Starting up rserver..."
    # RStudio Server 1.4.1103之前版本不需要--database-config-file,之后版本需要增加此配置
    singularity run -B "/tmp:/tmp","/data:/data" "$RSTUDIO_SERVER_IMAGE" ${RSTUDIO_RSERVER} \
      --www-port "${PORT}" \
      --auth-none 1 \
      --auth-pam-helper-path "${RSTUDIO_AUTH}" \
      --auth-encrypt-password 0 \
      --rsession-path "${RSESSION_WRAPPER_FILE}" \
      --server-data-dir "${TMPDIR}" \
      --server-user ${USER} \
      --secure-cookie-key-file "${TMPDIR}/rstudio-server/secure-cookie-key" \
      --database-config-file "${DB_CONF_FILE}" \
      --rsession-which-r ${WHICHR}

      echo 'Singularity as exited...'

  # 如何连接应用
  connect:
    method: POST
    path: /auth-do-sign-in
    formData:
      password: "{{ PASSWORD }}"
      username: "{{ USER }}"
      appUri: "{{ APPURI }}"

# 配置HTML表单   
attributes:
  - type: select
    name: r_version
    label: 请选择R版本
    select:
      - value: R-4.2.3
        label: 4.2.3
  - type: text
    name: sbatchOptions
    label: 其他sbatch参数
    required: false
    placeholder: "比如:--gpus gres:2 --time 10"
vanstriker commented 1 week ago

可能是交互式应用的配置问题,现在是否还会出现?

zhengkang2020 commented 1 week ago

还有这个问题,一直没处理。