Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-install some extensions on code-server notebook #347

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions codeserver/ubi9-python-3.9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ WORKDIR /opt/app-root/bin
RUN yum install -y "https://github.com/coder/code-server/releases/download/${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION/v/}-amd64.rpm" && \
yum -y clean all --enablerepo='*'

# Change ownership of relevant directories
RUN chmod -R g+w /opt/app-root/lib/python3.9/site-packages && \
fix-permissions /opt/app-root -P

# Install NGINX to proxy VSCode and pass probes check
ENV NGINX_VERSION=1.22 \
NGINX_SHORT_VER=122 \
Expand Down Expand Up @@ -78,8 +82,8 @@ COPY nginx/httpconf/ /opt/app-root/etc/nginx.d/
COPY nginx/api/ /opt/app-root/api/

# Launcher
COPY utils utils/
COPY run-code-server.sh run-nginx.sh ./
COPY --chown=1001:0 utils utils/
COPY --chown=1001:0 run-code-server.sh run-nginx.sh ./

ENV SHELL /bin/bash

Expand Down
25 changes: 25 additions & 0 deletions codeserver/ubi9-python-3.9/run-code-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ fi
# Initilize access logs for culling
echo '[{"id":"code-server","name":"code-server","last_activity":"'$(date -Iseconds)'","execution_state":"running","connections":1}]' > /var/log/nginx/vscode.access.log

# Check if code-server exists
if [ ! -f "/opt/app-root/src/.local/share/code-server" ]; then

# Check internet connection
if curl -Is http://www.google.com | head -n 1 | grep -q "200 OK"; then
# Internet connection is available
echo "Internet connection available. Installing specific extensions."

# Install specific extensions
code-server --install-extension ${SCRIPT_DIR}/utils/ms-python.python-2023.14.0.vsix
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.jupyter-2023.3.100.vsix
else
# No internet connection
echo "No internet connection. Installing all extensions."

# Install all extensions
code-server --install-extension ${SCRIPT_DIR}/utils/ms-python.python-2023.14.0.vsix
harshad16 marked this conversation as resolved.
Show resolved Hide resolved
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.jupyter-2023.3.100.vsix
harshad16 marked this conversation as resolved.
Show resolved Hide resolved
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.jupyter-keymap-1.1.2.vsix
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.jupyter-renderers-1.0.17.vsix
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.vscode-jupyter-cell-tags-0.1.8.vsix
code-server --install-extension ${SCRIPT_DIR}/utils/ms-toolsai.vscode-jupyter-slideshow-0.1.5.vsix
fi
fi

# Start server
start_process /usr/bin/code-server \
--bind-addr 0.0.0.0:8787 \
Expand Down
Binary file not shown.
Copy link

@shalberd shalberd Feb 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atheo89 is there a particular reason you selected Version 2023.3.100 for the Jupyter extension? when I go to marketplace visualstudio, I get 2024 versions and there are a bunch of changelogs for e.g. February 2024 milestone

Does it have something to do with Codeserver 4.16.1 vs. Visual Studio proper? I guess for one thing, the location to go to for extensions is openvsx vs the official marketplace. But then, even there, the latest version is 2023.9.100

coder/code-server#6323 (comment)

Codeserver 4.16.1 ist VS Code 1.80.2 https://github.com/coder/code-server/releases?page=2 so I guess that might have played a role in your considerations for 2023.3.100?

Disclaimer: I am asking because I've got some extension requests unrelated to these here from a user and just now getting into the topic, i.e. Codeserver custom container build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @shalberd , the reason we specifically selected these versions of the extension is to ensure compatibility with code-server version 4.16.1.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @atheo89 ok, from the vsx marketplace, or from the Github pages of the components, how can I see which code-server version or VS Code version the extension is for? I am looking for a kind of compatibility info. I do understand that
Codeserver 4.16.1 is VS Code 1.80.2, in essence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When installing an extension without specifying the version, code-server automatically selects the most compatible one. You can initially install them without specifying a version, then determine compatibility by running code --show-versions.

Copy link

@shalberd shalberd Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atheo89 found it, though with some research on stackoverflow, it is the package.json engine entry that shows the required version of code server / VS Code. https://github.com/microsoft/vscode-python/blob/main/package.json#L47 sorry for my long asking around, maybe this also helps others in future. Case closed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We downloaded the packages from vsx marketplace

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am mostly focused on offline install, that is why I was looking around for this info so much.

Copy link

@shalberd shalberd Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We downloaded the packages from vsx marketplace

Yes, but very un-user-friendly, the marketplace does not show the required code server / VS Code version. One always has to go to the engines section of package.json ...

You can initially install them without specifying a version, then determine compatibility by running code > --show-versions.

Yeah, though this is kinda complicated for a pure airgapped install, deciding which version to put into utils.

Thank you for your help, I know how to proceed now, also with more / other extensions to ensure compatibility (package.json)

Copy link

@shalberd shalberd Feb 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atheo89 @harshad16 there is a problem with this approach and current Notebooks when installing more than just these few extensions at runtime. The defaults for liveness and readiness probe times come from odh-dashboard, I think, when assembling the notebook CR.

          name: code-server-vs
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /notebook/dstst-analytix-fraud/code-server-vs/api
              port: notebook-port
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 5
            successThreshold: 1
            timeoutSeconds: 1

Because installing extensions takes some time at the code-server-vs/api health check endpoint is not up and running until after all extensions install and the nginx http server is running, the container keeps re-starting without more than 5 or 6 extensions ever installed.

I solved this by patching the notebook CR to have a large initialDelaySeconds of 100, so then code server started.

What do you think? @guimou do you have an idea of how to circumvent this problem of premature container restart due to failing liveness probes when installing more than, say, 6 or 7 extensions?

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.