microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.62k stars 277 forks source link

Attaching VS Code to a pod in Kubernetes behind a corporate proxy fails downloading VSCode Server #5287

Closed Bjego closed 3 years ago

Bjego commented 3 years ago

Hey guys, I'm trying to attach my Visual Studio Code to containers running in kubernetes on prem. Attaching fails while downloading the VSCode Server. My Pod has a proxy configured and also trusts the inhouse ssl cert.

When attaching the container the logs from VS Code are saying:

[21263 ms] Remote-Containers 0.183.0 in VS Code 1.57.1 (507ce72a4466fbb27b715c3722558bb15afa9f48).
[21262 ms] Start: Resolving Remote
[21266 ms] Start: Run: kubectl exec -it typescript-sq-developer-7754b4fdc4-wdm2n --context test --namespace crm-dev --container typescript-sq-developer -- /bin/sh -c VSCODE_REMOTE_CONTAINERS_SESSION='e72a2494-8e94-4053-ab97-47519a1e43791625473203780' /bin/sh
[21355 ms] Start: Run in container: id -un
[21637 ms] root
[21638 ms] Unable to use a TTY - input is not a terminal or the right kind of file
[21638 ms] Start: Run in container: uname -m
[21640 ms] x86_64
[21641 ms] 
[21641 ms] Start: Run in container: (cat /etc/os-release || cat /usr/lib/os-release) 2>/dev/null
[21643 ms] PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
[21643 ms] 
[21644 ms] Start: Run in container: cat /etc/passwd
[21647 ms] Start: Run in container: test -d /root/.vscode-server
[21649 ms] 
[21649 ms] 
[21650 ms] Start: Run in container: set -o noclobber ; mkdir -p '/root/.vscode-server/data/Machine' && { > '/root/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[21653 ms] 
[21653 ms] 
[21653 ms] Exit code 2
[21653 ms] Start: Run in container: cat /root/.vscode-server/data/Machine/settings.json
[21655 ms] 
[21655 ms] cat: /root/.vscode-server/data/Machine/settings.json: No such file or directory
[21655 ms] Exit code 1
[21656 ms] Start: Run in container: test -d /root/.vscode-server/bin/507ce72a4466fbb27b715c3722558bb15afa9f48
[21661 ms] 
[21662 ms] 
[21662 ms] Exit code 1
[21663 ms] Installing VS Code Server for commit 507ce72a4466fbb27b715c3722558bb15afa9f48
[21663 ms] Start: Downloading VS Code Server
[21663 ms] 507ce72a4466fbb27b715c3722558bb15afa9f48 x64 stable 
[21709 ms] Failed to download VS Code Server (https://update.code.visualstudio.com/commit:507ce72a4466fbb27b715c3722558bb15afa9f48/server-linux-x64/stable): HTTP 407 - authenticationrequired
chrmarti commented 3 years ago

Try setting your user setting "http.proxy" to your "http://user:password@mycorporateProxy.com:8080".

Bjego commented 3 years ago

Hi @chrmarti , yes my settings look like this:

{
...
  "http.proxySupport": "on",
  "http.proxy": "http://user:pass@mycorporateProxy.org:8080",
...
}

I even tried to sync the settings - also no luck. Any chance to get a more detailed log during connecting?

chrmarti commented 3 years ago

What type of authentication does your proxy require?

Bjego commented 3 years ago

Hi @chrmarti , I think it's basic auth or ntlm.

In the meanwhile I found a workaround with a prebuild container, where I install the vscode server based on the current commit id:

FROM mcr.microsoft.com/vscode/devcontainers/typescript-node
ARG commit=507ce72a4466fbb27b715c3722558bb15afa9f48
ADD https://update.code.visualstudio.com/commit:${commit}/server-linux-x64/stable /root/.vscode-server/bin/${commit}/dl.tar.gz
RUN tar -xvzf /root/.vscode-server/bin/${commit}/dl.tar.gz  --strip-components 1 -C /root/.vscode-server/bin/${commit}
RUN sudo chmod -R 777 /root/.vscode-server/bin

If this is a valid approach, how about adding this to the docs. Something like :

Prebuild containers with a vscode-server, in case you do have issues downloading the latest server on demand. Get your current commit id -> VSCode -> Help -> About -> Copy Values Build your container like this (see code above)

chrmarti commented 3 years ago

That's a great workaround. I'm hesitant to add this to the documentation since it's such an edge case.

Closing this issue, thanks.

baileydoestech commented 3 years ago

@Bjego we are using your workaround to address #5085 which resovles the certificate error but results in the following, is this something you saw as well? If not then @chrmarti is this approach still a viable option or no longer supported?

[2021-08-10T13:22:12.414Z] Start: Run in container: /root/.vscode-server/bin/2aeda6b18e13c4f4f9edf6667158a6b8d408874b/server.sh --log debug --force-disable-user-env --port 0 --extensions-download-dir /root/.vscode-server/extensionsCache --start-server 
[2021-08-10T13:22:12.918Z] Error: stream ended with:124 but wanted:1128865906