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

Apply shutdown timeout to http server to limit reload delay #14339

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

carsonip
Copy link
Member

@carsonip carsonip commented Oct 11, 2024

Motivation/summary

httpServer.stop may block indefinitely, potentially due to misbehaving connections.

Apply shutdown timeout to http server so that in a hot reload, the old and new server overlapping time is bounded.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

May need to change the code to hang the http server to observe the shutdown timeout. Alternatively there may be a way to mock a misbehaving http client without code change.

Related issues

Part of #14337

Copy link
Contributor

mergify bot commented Oct 11, 2024

This pull request does not have a backport label. Could you fix it @carsonip? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.17 is the label to automatically backport to the 7.17 branch.
  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • backport-8.x is the label to automatically backport to the 8.x branch.

Copy link
Contributor

mergify bot commented Oct 11, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Oct 11, 2024
// httpServer should stop before grpcServer to avoid a panic caused by placing a new connection into
// a closed grpc connection channel during shutdown.
// See https://github.com/elastic/gmux/issues/13
s.httpServer.stop()
s.grpcServer.GracefulStop()
Copy link
Member Author

@carsonip carsonip Oct 11, 2024

Choose a reason for hiding this comment

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

[to reviewer] Moving grpcServer.GracefulStop ahead of httpServer.stop, as this was how the code was originally written before elastic/gmux#13 was discovered. Now that it is fixed, we can revert it, so that it sends GOAWAY to grpc clients.

@carsonip carsonip marked this pull request as ready for review October 11, 2024 10:18
@carsonip carsonip requested a review from a team as a code owner October 11, 2024 10:18
kruskall
kruskall previously approved these changes Oct 11, 2024
1pkg
1pkg previously approved these changes Oct 11, 2024
Copy link
Contributor

mergify bot commented Oct 14, 2024

This pull request is now in conflicts. Could you fix it @carsonip? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b limit-reload-delay upstream/limit-reload-delay
git merge upstream/main
git push upstream limit-reload-delay

@carsonip carsonip dismissed stale reviews from 1pkg and kruskall via d38d5d4 October 14, 2024 13:38
@carsonip carsonip requested review from 1pkg and kruskall October 14, 2024 13:39
@carsonip carsonip enabled auto-merge (squash) October 14, 2024 13:41
@carsonip carsonip merged commit 24329c8 into elastic:main Oct 15, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Oct 15, 2024
httpServer.stop may block indefinitely, potentially due to misbehaving connections.

Apply shutdown timeout to http server so that in a hot reload, the old and new server overlapping time is bounded.

(cherry picked from commit 24329c8)
mergify bot added a commit that referenced this pull request Oct 15, 2024
…14362)

httpServer.stop may block indefinitely, potentially due to misbehaving connections.

Apply shutdown timeout to http server so that in a hot reload, the old and new server overlapping time is bounded.

(cherry picked from commit 24329c8)

Co-authored-by: Carson Ip <[email protected]>
@rubvs rubvs mentioned this pull request Oct 29, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants