Skip to content
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

fix: Ensure HTTP server startup errors are logged (#694) #700

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

Conversation

mrashad10
Copy link

Bugfixes

PR Description

This commit modifies the go routine that starts the HTTP server to explicitly log any errors encountered during startup, except for http.ErrServerClosed, which is expected during graceful shutdown. This change ensures that issues related to the server's startup, such as the address already being in use, are logged, making it easier to diagnose and fix.

Which issue(s) this PR fixes

Fixes #694

Notes to the Reviewer

PR Checklist

This commit modifies the goroutine that starts the HTTP server to explicitly log any errors encountered during startup, except for `http.ErrServerClosed`, which is expected during graceful shutdown. This change ensures that issues related to the server's startup, such as the address already being in use, are logged, making it easier to diagnose and fix.

Closes grafana#694
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Mohamad Rashad seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mrashad10
Copy link
Author

As this is my first contribution, I welcome all your feedback and advice.

@@ -44,7 +44,11 @@ func main() {
}()
log.Printf("HTTP server on %s", listenAddress)

go func() { log.Fatal(server.ListenAndServe()) }()
go func() {
Copy link
Contributor

@hainenber hainenber Apr 30, 2024

Choose a reason for hiding this comment

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

I think you made changes in the wrong place. This main.go's purpose is to run integration tests.

Robert already pointed at possibility of logging out the error before return it here. Could use something like level.Error(s.log).Log("failed to start HTTP service", "msg", err.Error()

return fmt.Errorf("failed to listen on %s: %w", s.opts.HTTPListenAddr, err)

@rfratto rfratto added the backport-to-agent PR should be backported to the agent repo. label May 3, 2024
@hainenber
Copy link
Contributor

hi @mrashad10, are you still working on this PR? If anything's troubling you, feel free to raise it here!

@mrashad10
Copy link
Author

Hi @hainenber

Sorry but I was busy last 2 weeks, I'm not sure that I will have time to work on it this week too.

Copy link
Contributor

This PR has not had any activity in the past 30 days, so the needs-attention label has been added to it.
If you do not have enough time to follow up on this PR or you think it's no longer relevant, consider closing it.
The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your PR will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity.
Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-agent PR should be backported to the agent repo. needs-attention
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No error logs when the HTTP server cannot start
4 participants