vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Some remote servers not shutting down

Open roblourens opened this issue 4 years ago • 5 comments
trafficstars

image

These are servers from several insiders builds going back to 9 days ago. They should shut down when there are no active EH connections for a few hours. Do you know if anything changed @alexdima?

Looking at the server log, most were started and never got a connection:

image

Just one of them did have connections and it looks like it tried to shut down:

image

And that's a strange place to stop

image

roblourens avatar Jan 28 '21 19:01 roblourens

The only thing that I can think of is that this.dispose() throws which prevents execution from reaching process.exit(0). The registered disposables are:

  • FileService
  • DiskFileSystemProvider
  • appInsightsAppender.flush()
  • ErrorTelemetry Perhaps one of these decides to throw in their dispose method. I've added server-side start-up telemetry, so it might be the appInsightsAppender.

But this doesn't explain the other servers not going down. I never 100% understood the auto-shutdown logic you added here, could you walk me through it?

alexdima avatar Jan 28 '21 19:01 alexdima

It looks to me that perhaps _waitThenShutdown should be called from the initialize method as well? Otherwise a server without any connections will never shut down by itself, as you observe?

alexdima avatar Jan 28 '21 19:01 alexdima

I can add a try/finally on that, although I would expect the exception to show up in the log...

So looking at the code, I'm wondering whether it actually broke recently or if this is a missing case. If you go through reconnection after a long time when the remote agent has shut down, then the ssh resolver will start an agent, and vscode will connect to it, and it decides that its EH is gone. So it never gets an EH. So either we need to start the timer right away or change the ssh resolver to not start a new agent during reconnection.

roblourens avatar Jan 28 '21 19:01 roblourens

Yeah I guess it should be safe to start an agent that never gets a connection. If this isn't new then I don't know why I don't have 12 months of agents running. But I'm trying to see if it reproes in stable.

roblourens avatar Jan 28 '21 19:01 roblourens

Stable has this same behavior, I'll fix it in Feb

roblourens avatar Jan 29 '21 00:01 roblourens

Steps

  • Connect to a Remote-SSH host
  • Separately ssh yourHost in a local terminal in another window, so you can run commands without a vscode server
  • In that terminal, run ps ax | grep server-main and verify that the vscode server from step 1 shows up
  • In a local vscode window, run "Kill VS Code Server on Host", pick the host that you connected to in step 1. This kills that server process
  • Verify that window gets permanently disconnected
  • In the ssh terminal, run the ps command again and verify that a server appears, it was started by the window trying to reconnect
  • Wait at least 5 minutes
  • In the ssh terminal, run the ps command again and verify that the server has shut down, since it never got a successful connection

roblourens avatar Jan 27 '23 22:01 roblourens