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

stop healthz http server cleanly #1535

Merged
merged 1 commit into from
Feb 18, 2022
Merged

stop healthz http server cleanly #1535

merged 1 commit into from
Feb 18, 2022

Conversation

nuczzz
Copy link
Contributor

@nuczzz nuczzz commented Jan 29, 2022

Description

stop healthz http server cleanly

Todos

  • Tests
  • Documentation
  • Release note

Release Note

None required

Copy link
Collaborator

@manuelbuil manuelbuil left a comment

Choose a reason for hiding this comment

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

I only have a question. The rest looks good :)

wg.Add(2)
go func() {
// when Shutdown is called, ListenAndServe immediately return ErrServerClosed.
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why && !errors.Is(err, http.ErrServerClosed)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We will call server.Shutdown() to shutdown healthz http server when global context is done, and when server.Shutdown() is called, the first goroutine function server.ListenAndServe() immediately return http.ErrServerClosed, so it means we will get http.ErrServerClosed when healthz http server close normally, and close normally should not panic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks

@luthermonson
Copy link
Contributor

@manuelbuil if you dont have any issues with this we will merge. i think it's clean and gtg

@manuelbuil manuelbuil merged commit e8339a6 into flannel-io:master Feb 18, 2022
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.

3 participants