Skip to content

add sigint and sigterm support for logs when follow flag is used #13132

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

glours
Copy link
Contributor

@glours glours commented Aug 5, 2025

What I did
Add a channel to monitor SIGINT and SIGTERM and exit immediately the logs command when -f or --follow flag is used

Related issue
Fix #13118

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@glours glours requested a review from a team as a code owner August 5, 2025 08:32
@glours glours requested a review from ndeloof August 5, 2025 08:32
@glours glours self-assigned this Aug 5, 2025
Comment on lines 114 to 116
eg.Go(func() error {
return monitor.Start(ctx)
})
Copy link
Contributor

@alessio-perugini alessio-perugini Aug 7, 2025

Choose a reason for hiding this comment

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

Suggested change
eg.Go(func() error {
return monitor.Start(ctx)
})
eg.Go(func() error {
return monitor.Start(ctx)
})

Sorry if I jump in, but I got bitten by the recent change done by #13062.
With the fix you propose in this PR I'm afraid we'll have a goroutine leak. I think the monitor.Start will keep running.

Considering only this codebase's use case for the Logs function, the leak won't be a big deal because you always quit the process. However, this will become a problem for other users who use this method (Logs) and do not want to terminate the process.

I think it would be great if we could pass to the monitor.Start/newMonitor something to make it go back the old behaviour (quitting the monitor upon context cancellation)

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.

[BUG] logs -f is not terminated by Ctrl-C / SIGINT
2 participants