Skip to content

fix: track JetBrains connections #10968

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

Merged
merged 12 commits into from
Dec 7, 2023
Merged

fix: track JetBrains connections #10968

merged 12 commits into from
Dec 7, 2023

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Dec 1, 2023

Fixes #9673

Possibly we will need to find a better string to match on, but this one seems OK to me.

Unit test passes but have not tested an actual deploy yet.

@code-asher code-asher changed the title Track JetBrains connections fix: track JetBrains connections Dec 1, 2023
@code-asher code-asher force-pushed the jetbrains/track_connections branch from 7948ab5 to e7f9516 Compare December 1, 2023 00:24
@matifali
Copy link
Member

matifali commented Dec 1, 2023

@code-asher Try ./scripts/deploy-pr.sh

@code-asher
Copy link
Member Author

Verified it works! 🎉

@code-asher code-asher marked this pull request as ready for review December 1, 2023 19:50
@code-asher code-asher requested a review from Emyrk December 1, 2023 19:53
@code-asher code-asher force-pushed the jetbrains/track_connections branch 2 times, most recently from fe83fbd to 9dede7f Compare December 1, 2023 20:18
@code-asher code-asher removed the request for review from Emyrk December 1, 2023 20:19
@code-asher
Copy link
Member Author

Ah wait moving back to draft, there seems to be an issue...

@code-asher code-asher marked this pull request as draft December 1, 2023 20:20
@code-asher code-asher force-pushed the jetbrains/track_connections branch from 9dede7f to 9840a69 Compare December 1, 2023 20:45
@code-asher
Copy link
Member Author

The two issues I ran into, just FYI:

  • I had the process name check reversed, needed a ! 🤦
  • Netstat only gives the base name, not the full command line, so I need to read /proc/$pid/cmdline to get that.

I think it is all sorted now, doing some more testing to be sure.

@code-asher
Copy link
Member Author

OK, verified it all works as expected in a deployment. Test is failing in CI though. Passes for me locally...

@Emyrk
Copy link
Member

Emyrk commented Dec 1, 2023

Test is failing in CI though. Passes for me locally...

Ooof, this test is quite strange too. That sounds annoying to debug...

Use t.Log() to log statements, and keep them there.

code-asher and others added 6 commits December 1, 2023 12:05
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
@code-asher code-asher force-pushed the jetbrains/track_connections branch from 64ea05d to 6e8f235 Compare December 1, 2023 21:06
@matifali
Copy link
Member

matifali commented Dec 1, 2023

Will this also work for Fleet?

@code-asher code-asher force-pushed the jetbrains/track_connections branch from e79b01c to ec59e7e Compare December 1, 2023 21:27
@code-asher
Copy link
Member Author

Will this also work for Fleet?

I am not sure, we will need to test.

@code-asher code-asher force-pushed the jetbrains/track_connections branch from ec59e7e to 90e6e88 Compare December 1, 2023 21:43
@code-asher code-asher force-pushed the jetbrains/track_connections branch 2 times, most recently from 9cf5082 to 7fd04cb Compare December 1, 2023 23:19
The test name only shows up in the process name if you are running that
test directly so we have to spawn a separate process instead.
@code-asher code-asher force-pushed the jetbrains/track_connections branch from 7fd04cb to a75ed6c Compare December 1, 2023 23:26
@code-asher
Copy link
Member Author

OK, sorted the test. The test name only shows up in the process name if you run that specific test directly, so when we are running the entire suite the name does not show up.

What I did was spawn an external process instead. Not sure if I did it in an idiomatic way or if there even is an idiomatic way, with Node I would just fork to create child processes using the same Node binary but I am not seeing an equivalent in Go, at least not without a new package dependency. So I have this janky exec.Command("go", "run", ...) type of deal.

We could also try spawning something like nc instead of a Go program. but I am not sure how commonly nc is installed.

@code-asher code-asher marked this pull request as ready for review December 1, 2023 23:33
@code-asher code-asher requested a review from Emyrk December 1, 2023 23:33
Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

Looks good, let's get this in and test it a bit.

@code-asher code-asher merged commit dbbf8ac into main Dec 7, 2023
@code-asher code-asher deleted the jetbrains/track_connections branch December 7, 2023 21:15
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API: /api/v2/deployment/stats does not return count for JetBrains Gateway sessions
3 participants