8000 Added graceful shutdown timeout by almostinf · Pull Request #1825 · grafana/beyla · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Added graceful shutdown timeout #1825

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 14 commits into from
Apr 16, 2025
Merged

Conversation

almostinf
Copy link
Contributor

Refactored of starting beyla components and added a graceful shutdown timeout

Closes #820

@almostinf almostinf requested review from grafsean and a team as code owners April 12, 2025 18:51
@@ -45,6 +45,7 @@ const (
var DefaultConfig = Config{
ChannelBufferLen: 10,
LogLevel: "INFO",
ShutdownTimeout: 5 * time.Minute,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what is the best default time to set, left it pretty big imho

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be few seconds (maybe 10?). Actually Kubernetes would kill Beyla before that timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, changed it to 10 seconds, thanks

Copy link
codecov bot commented Apr 12, 2025

Codecov Report

Attention: Patch coverage is 70.70707% with 29 lines in your changes missing coverage. Please review.

Project coverage is 74.28%. Comparing base (9a58323) to head (7d82a00).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/components/beyla.go 51.85% 9 Missing and 4 partials ⚠️
pkg/internal/appolly/appolly.go 76.92% 7 Missing and 2 partials ⚠️
pkg/internal/netolly/agent/agent.go 78.78% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1825      +/-   ##
==========================================
+ Coverage   70.23%   74.28%   +4.04%     
==========================================
  Files         173      177       +4     
  Lines       18435    19222     +787     
==========================================
+ Hits        12948    14279    +1331     
+ Misses       4646     4214     -432     
+ Partials      841      729     -112     
Flag Coverage Δ
integration-test 57.48% <68.68%> (-0.14%) ⬇️
k8s-integration-test 55.60% <68.68%> (-0.06%) ⬇️
oats-test 35.66% <39.39%> (-0.04%) ⬇️
unittests 46.04% <6.06%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor
@mariomac mariomac left a comment

Choose a reason for hiding this comment

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

Amazing!! Thanks for the contribution. I have few comments for discussion.

@@ -45,6 +45,7 @@ const (
var DefaultConfig = Config{
ChannelBufferLen: 10,
LogLevel: "INFO",
ShutdownTimeout: 5 * time.Minute,
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be few seconds (maybe 10?). Actually Kubernetes would kill Beyla before that timeout.


// of one of both nodes fail, the other should stop
ctx, cancel := context.WithCancel(ctx)
errs := make(chan error, 2)
g, ctx := errgroup.WithContext(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!! Didn't know this tool.

go func() {
log := log()
for {
select {
case <-i.ctx.Done():
log.Debug("stopped searching for new processes to instrument. Waiting for the eBPF tracers to be unloaded")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd anyway log the messages, for debugging purposes.

Copy link
Contributor Author
@almostinf almostinf Apr 14, 2025

Choose a reason for hiding this comment

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

This log is also still there, just moved to Instrumenter.stop() :)


return nil
func (i *Instrumenter) Stop() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to move the stop/wait code to a function that needs to be explicitly invoked?

Maybe it's just a personal taste, but the previous version looked more "self-contained" as it was a single function invocation.

Copy link
Contributor Author
@almostinf almostinf Apr 14, 2025

Choose a reason for hiding this comment

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

yeah, a matter of taste, but no problem, I returned a single call to the public run function and made the stop function private

@almostinf almostinf requested a review from mariomac April 14, 2025 20:52
@CLAassistant
Copy link
CLAassistant commented Apr 15, 2025

CLA assistant check
All committers have signed the CLA.

@almostinf almostinf force-pushed the feature/force-stop branch from d3a5df9 to 9bfd941 Compare April 15, 2025 19:06
Copy link
Contributor
@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM! This looks great to me.

I think there are still some problems with the merge with main, supposedly you still need to run make update-licenses, but the complaints are with Beyla v2 paths.

@almostinf
Copy link
Contributor Author

@grcevski thanks, fixed the pipeline :)

@grcevski grcevski merged commit e32388d into grafana:main Apr 16, 2025
14 checks passed
@grcevski
Copy link
Contributor

Thanks so much again for your contribution @almostinf !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kill beyla if it does not stop after a given timeout
4 participants
0