Description
Jetbrains Gateway creates many ssh sessions to connect to coder workspaces. After some digging into the underlying behavior, I've noticed that Jetbrains Gateway plugin will create ssh sessions when opening an IDE to a workspace and upon closing the IDE the ssh connections will be held open until the gateway client is closed.
After opening and closing the IDE to a workspace you can see the ssh session open still:
ps aux | grep -e "--usage-app="
f0ssel 28578 1.2 0.2 409780816 41840 ?? S 3:25PM 0:00.46 /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/coder-darwin-arm64 --global-config /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/config --url http://localhost:3000 ssh --stdio --disable-autostart --usage-app=jetbrains admin/jetbrains1.main
f0ssel 28502 0.7 0.2 409790336 37376 ?? S 3:25PM 0:00.45 /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/coder-darwin-arm64 --global-config /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/config --url http://localhost:3000 ssh --stdio --disable-autostart --usage-app=disable admin/jetbrains1.main
f0ssel 28595 0.6 0.2 409788496 40704 ?? S 3:25PM 0:00.21 /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/coder-darwin-arm64 --global-config /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/config --url http://localhost:3000 ssh --stdio --disable-autostart --usage-app=jetbrains admin/jetbrains1.main
f0ssel 28517 0.4 0.2 409780304 36384 ?? S 3:25PM 0:00.31 /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/coder-darwin-arm64 --global-config /Users/f0ssel/Library/Application Support/coder-gateway/localhost-3000/config --url http://localhost:3000 ssh --stdio --disable-autostart --usage-app=disable admin/jetbrains1.main
f0ssel 28695 0.0 0.0 408626896 1408 s001 S+ 3:25PM 0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox -e --usage-app=
Because these are held open they will continue to bump workspace activity indefinitely despite no active IDE session to the workspace. While collaborating with @code-asher we were able to isolate this behavior down to to Jetbrains Gateway (not our plugin code) and @code-asher is filing a bug with Jetbrains directly with our reproduction steps. We've ruled out that this could be related to coder ssh
by reproducing this issue with a regular ssh command in the ProxyCommand config and still seeing the same issue.
In legacy workspace activity tracking we solved this by tracking the port-forward session at the agent ssh server and this is accurately tracking usage today. In the new workspace activity system this behavior is a problem because we rely on the client sending us activity updates, and if the client is incorrectly holding open ssh connections for hours on end we can't tell from our side that this activity update is invalid and we will continue to record activity to the workspace long after the IDE has been closed.