Vscode code-server

Hi,

We’re trying to get the latest vs code working as an app (https://github.com/cdr/code-server) and hitting a bit of a snag. We have more or less the same setup as at https://github.com/OSC/bc_osc_codeserver but the code-server login redirects and gets a broken URL with duplicated server/port in it. Once the interactive app starts and we click launch we get a

404 Not Found

on the URL:

https://ushpc-ondemand.gsk.com/rnode/cpu-305.cm.storage/21505/rnode/cpu-305.cm.storage/21505/

If I then modify that URL to be

https://ushpc-ondemand.gsk.com/rnode/cpu-305.cm.storage/21505/

VS Code works fine after that. Is there a way to get OnDemand to do the right thing here or is this something that needs to be addressed in code-server upstream?

Here’s the output from code-server, showing the redirect that takes place at login:

+ /home/jbh41678/code-server/code-server --log trace --disable-telemetry --host 0.0.0.0 --port 21505
debug spawned inner process 97580
debug parsed command line e[38;2;140;140;140m{"args":{"_":[],"log":"trace","disable-telemetry":true,"host":"0.0.0.0","port":21505}}e[0m
debug wrapper 97522 received message from 97580 e[38;2;140;140;140m{"message":{"type":"handshake"}}e[0m
debug inner process 97580 received message from 97522 e[38;2;140;140;140m{"message":{"type":"handshake"}}e[0m
info  code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f
info  HTTP server listening on http://0.0.0.0:21505
info    - Using custom password for authentication
info    - Not serving HTTPS
info  Automatic updates are enabled
Discovered VS Code Notebook server listening on port 21505!
TIMING - Wait ended at: Thu Apr 30 19:22:56 EDT 2020
Generating connection YAML file...
trace heartbeat
debug redirecting e[38;2;140;140;140m{"secure":false,"from":"/login","to":"./"}e[0m
debug Request error e[38;2;140;140;140m{"url":"/rnode/cpu-305.cm.storage/21505/","code":404}e[0m
debug forking vs code...
debug got message from vs code e[38;2;140;140;140m{"message":{"type":"ready"}}e[0m
debug setting up vs code...

Best,

griznog

We are working through the same problem! Will keep you posted when we find a solution.

@griznog I’ve been working on this and have a working branch available for testing. We have a few bugs to iron out but please try out what we have so far and let us know what you think! https://github.com/OSC/bc_osc_codeserver/pull/2

This bug happens because of the way reverse proxying is implemented currently in OOD, but we have a fix available in the pull request above.

Thanks for efforts on this, we’ve continued poking at it with mixed results. The latest release of code-server (3.3.1) hasn’t worked well at all in or out of ondemand. Will update if we suddenly find ourselves in possession of a stable code-server solution :slight_smile:

What’s your current issue? We used @mario solution with 3.3.1. We did have to remove a deprecated flag --disable-updates from the code-server startup.

For reference we have code-server running in a CentOS 7 singularity container.

@maflister Awesome to hear! Would you be willing to share your solution that uses a Singularity container?

I updated the PR to support code-server version 3.3.1 and removed the --disable-updates flag

We use the following Singularity recipe:

Bootstrap: docker
From: centos:7

%labels
Maintainer Matthew Flister

%help
This container includes code server running VS Code.

%environment
    SHELL=/bin/bash
    PATH=$PATH:/opt/code-server
    export SHELL PATH
    source scl_source enable rh-git218

%post
    # Install necessary packages
    yum update -y && yum install -y wget python3 gcc g++
    yum install -y centos-release-scl
    yum install -y rh-git218
    yum clean all

    # install code-server
    wget https://github.com/cdr/code-server/releases/download/v3.3.1/code-server-3.3.1-linux-amd64.tar.gz
    tar -xvf code-server-3.3.1-linux-amd64.tar.gz
    cp -R code-server-3.3.1-linux-amd64 /opt/code-server
    rm -rf code-server-3.3.1-linux-amd64

Then we specify in script.sh.erb:
CODE_SERVER="singularity exec code-server-3.3.1_latest.sif code-server"

2 Likes

I’m still having the same issue here, i.e. after logging in the get the URL:

DOMAIN/rnode/HOST/PORT/rnode/HOST/PORT

And, I need to manually remove the last “rnode/HOST/PORT”. Is there a fix for this?

Thanks,
Paul

@edwardsp

I have a working branch for Code Server that gets around this issue:

This issue stems from some assumptions that the OOD reverse proxy makes, there’s an open issue here: https://github.com/OSC/ondemand/issues/493

Hello, Thank you for posting your singularity recipe. I am struggling to get code-server to run using singularity. May I know what is the content for file scl_source?

I am able to do this far:
with the following steps proceed ok :

  • I save the recipe file in my directory as vscode.recipt.
  • As a root user on a linux server, use commands
    module load singularity/3.7.0
    singularity build vscode.sif vscode.recipe
    to build a vscode.sif;

However, I am not able to run vscode.sif? Missing scl_source is the first complain. May you please kindly provide me more details of building and running this singularity code-server container. Thanks in advance.

Hi. The purpose of SCL in that container is to support a newer version of git. However, if you don’t need git, you can remove those portions. Also, I should mention that we no longer use this container in production. We originally created it because our host OS (CentOS 6) did not support VSCode. However, we now use CentOS 7 and do not need the container. I’d suggest to not use container if your host OS is CentOS 7. If you will use the container, I’d suggest to remove these lines:

    source scl_source enable rh-git218
    yum install -y centos-release-scl
    yum install -y rh-git218

Hello!

Thank you very much for your reply and providing suggestion.

Best,

Rong Yao

@mario Hi. I’m just looking at doing this now and have the same issue as originally reported with the 404 error. Are your changes merged in the latest release of bc_osc_codeserver? That’s the one I’m using and still have the issue.

I’m using OOD 2.0.13. It does look like the code-server is launching ok, and I can connect directly to it on the node that it’s running on, but the URL is malformed like was described here.

@mario Hi again. I wanted to post an update. It seems like the problems I’m seeing are specific (maybe) to 3.11.1. I tried code-server version 3.10.2 and do not have an issue. Seems like the code-server developers may have done some reverse proxy work that might be conflicting with OOD.