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.69k stars 299 forks source link

Host networking: High CPU and memory usage which eventually crashes docker. #10254

Open mliudev opened 2 months ago

mliudev commented 2 months ago

Original issue #214673 described similar behavior as mine. These vscode-server/bin processes seem to be infinitely spinning up until OOM.

Screenshot 2024-06-12 at 15 26 00

Originally posted by @mliudev in https://github.com/microsoft/vscode/issues/214673#issuecomment-2164001700

devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
    "name": "Node.js & TypeScript",
    // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
    "image": "mcr.microsoft.com/devcontainers/typescript-node:20",
    "runArgs": ["--network=host"],
    "postCreateCommand": "git config --global --add safe.directory /workspaces/Playground",
    "customizations": {
        "vscode": {
            "extensions": [
                "esbenp.prettier-vscode",
                "dbaeumer.vscode-eslint",
                "ionutvmi.path-autocomplete",
                "github.vscode-github-actions",
                "ms-azuretools.vscode-docker",
                "clinyong.vscode-css-modules",
                "eamodio.gitlens"
            ],
            "settings": {
                "typescript.tsdk": "node_modules/typescript/lib",
                "typescript.enablePromptUseWorkspaceTsdk": true,
                "typescriptreact.preferGoToSourceDefinition": true,
                "[scss]": {
                    "editor.defaultFormatter": "esbenp.prettier-vscode"
                },
                "remote.localPortHost": "allInterfaces",
                "cssModules.pathAlias": {
                    "@/common": "${workspaceFolder}/src/common",
                    "@/app/(app)": "${workspaceFolder}/src/app"
                },
                "search.exclude": {
                    "**/.git": true,
                    "**/.svn": true,
                    "**/.hg": true,
                    "**/CVS": true,
                    "**/.DS_Store": true,
                    "**/Thumbs.db": true,
                    ".next": true,
                    "node_modules": true
                }
            }
        }
    },
    "features": {
        "ghcr.io/devcontainers-contrib/features/firebase-cli:2": {}
    }
}
mliudev commented 2 months ago

Related to https://github.com/microsoft/vscode-remote-release/issues/9996 and https://github.com/microsoft/vscode-remote-release/issues/9821.

mliudev commented 2 months ago

Some more info is that there appears to be an infinite loop of port forwarding. Not sure what this port is being forwarded for:

devcontainer log

[21274 ms] Port forwarding 52905 > 58319 > 58319 stderr: Connection established
[21282 ms] Port forwarding connection from 52907 > 58319 > 58319 in the container.
[21282 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21358 ms] Port forwarding 52907 > 58319 > 58319 stderr: Connection established
[21377 ms] Port forwarding connection from 52909 > 58319 > 58319 in the container.
[21377 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21442 ms] Port forwarding 52909 > 58319 > 58319 stderr: Connection established
[21452 ms] Port forwarding connection from 52911 > 58319 > 58319 in the container.
[21452 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21597 ms] Port forwarding 52911 > 58319 > 58319 stderr: Connection established
[21608 ms] Port forwarding connection from 52913 > 58319 > 58319 in the container.
[21608 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21706 ms] Port forwarding 52913 > 58319 > 58319 stderr: Connection established
[21716 ms] Port forwarding connection from 52916 > 58319 > 58319 in the container.
[21716 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21769 ms] Port forwarding 52916 > 58319 > 58319 stderr: Connection established
[21801 ms] Port forwarding connection from 52918 > 58319 > 58319 in the container.
[21801 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21903 ms] Port forwarding 52918 > 58319 > 58319 stderr: Connection established
[21911 ms] Port forwarding connection from 52924 > 58319 > 58319 in the container.
[21911 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[21988 ms] Port forwarding 52924 > 58319 > 58319 stderr: Connection established
[21995 ms] Port forwarding connection from 52926 > 58319 > 58319 in the container.
[21996 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22063 ms] Port forwarding 52926 > 58319 > 58319 stderr: Connection established
[22075 ms] Port forwarding connection from 52928 > 58319 > 58319 in the container.
[22075 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22145 ms] Port forwarding 52928 > 58319 > 58319 stderr: Connection established
[22155 ms] Port forwarding connection from 52930 > 58319 > 58319 in the container.
[22155 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22253 ms] Port forwarding 52930 > 58319 > 58319 stderr: Connection established
[22333 ms] Port forwarding connection from 52932 > 58319 > 58319 in the container.
[22333 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22417 ms] Port forwarding 52932 > 58319 > 58319 stderr: Connection established
[22422 ms] Port forwarding connection from 52934 > 58319 > 58319 in the container.
[22423 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22514 ms] Port forwarding 52934 > 58319 > 58319 stderr: Connection established
[22523 ms] Port forwarding connection from 52936 > 58319 > 58319 in the container.
[22523 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22634 ms] Port forwarding 52936 > 58319 > 58319 stderr: Connection established
[22639 ms] Port forwarding connection from 52938 > 58319 > 58319 in the container.
[22640 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22701 ms] Port forwarding 52938 > 58319 > 58319 stderr: Connection established
[22707 ms] Port forwarding connection from 52940 > 58319 > 58319 in the container.
[22708 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22765 ms] Port forwarding 52940 > 58319 > 58319 stderr: Connection established
[22773 ms] Port forwarding connection from 52942 > 58319 > 58319 in the container.
[22773 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22856 ms] Port forwarding 52942 > 58319 > 58319 stderr: Connection established
[22907 ms] Port forwarding connection from 52948 > 58319 > 58319 in the container.
[22908 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[22973 ms] Port forwarding 52948 > 58319 > 58319 stderr: Connection established
[22979 ms] Port forwarding connection from 52950 > 58319 > 58319 in the container.
[22979 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[23034 ms] Port forwarding 52950 > 58319 > 58319 stderr: Connection established
[23043 ms] Port forwarding connection from 52952 > 58319 > 58319 in the container.
[23043 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
[23146 ms] Port forwarding 52952 > 58319 > 58319 stderr: Connection established
[23157 ms] Port forwarding connection from 52954 > 58319 > 58319 in the container.
[23157 ms] Start: Run in container: /root/.vscode-server/bin/4849ca9bdf9666755eb463db297b69e5385090e3/node -e 
chrmarti commented 2 months ago

Not sure how this gets triggered, but removing "runArgs": ["--network=host"], from the config probably works around it. Could you try that?

Does the Ports view show a port being forwarded?

Could you append the full log?

mliudev commented 2 months ago

Is the --network=host not necessary? We actually do want the docker container to have host networking. If it happens again I'll try to get the full log but it happens intermittently.

mliudev commented 2 months ago

Also, how exactly do I open the DevContainer logs if I miss the notification? It doesn't look like I can go to Output and select it as one of the logs.

mliudev commented 2 months ago

I tried to get the full log but it's incredibly spammy and couldn't fit into my clipboard. It's just opening ports repeatedly as fast as it possibly can.

mliudev commented 2 months ago

The port does appear to be auto forwarded in a container that doesn't have the issue. I'm not actually sure if it is in a buggy container. Screenshot 2024-09-13 at 3 15 08 PM

chrmarti commented 2 months ago

You can use F1 > Dev Containers Developer: Show All Logs... to get at the history of logs. It would be interesting to see the start of the log until it goes into the loop. Does rebuilding the dev container help? It looks like it is trying to connect to the VS Code Server, but just ends up in that loop, not sure why this wouldn't happen with all containers using host networking.

mliudev commented 2 months ago

Is there log folder that I might be able to find these logs in after closing the container? It basically drains all the resources of the docker engine and makes it really slow and eventually crashes it when it uses all allocated memory.

chrmarti commented 2 months ago

That command should also be available in a new window and include logs from previous sessions.

mliudev commented 2 months ago

I've uploaded the log.

remoteContainers-2024-09-13T13-18-12.819Z.log

chrmarti commented 2 months ago

Somehow the connection inside the container always picks up the forwarded port from the host and not the VS Code Server in the container. Host networking is triggering it.

mliudev commented 2 months ago

Is this a VSCode or Docker problem?

mliudev commented 2 months ago

Just FYI, this is happening on a daily basis now. I've had it happen multiple times per session even.