-
Notifications
You must be signed in to change notification settings - Fork 716
feat: Gracefully drain listeners before envoy shutdown on pod termination #2633
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
arkodg
merged 34 commits into
envoyproxy:main
from
davidalger:algerdev/graceful-pod-termination
Feb 27, 2024
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b4baa8f
feat: Gracefully drain listeners before envoy shutdown on pod termina…
davidalger 2b9d79c
Setup hooks to manage graceful Envoy shutdown process
davidalger fa8ad3a
Implement graceful drain process in shutdown-manager
davidalger 9a8b290
Send logs from exec prestop hook to stdout of main process
davidalger 666275e
Merge branch 'main' into algerdev/graceful-pod-termination
davidalger 367d4a3
Make linter happy
davidalger b2e68b1
Minor cleanup
davidalger 4a3b90f
Stop polling when ready-timeout exceeded
davidalger fa0f1ec
Container configuration for shutdown manager
davidalger 23144c9
Setup health probes
davidalger 62ec399
Configurable shutdown timeouts
davidalger b3bc785
Correct exitAtConnections logic
davidalger 561530a
Lower shutdown timeouts for conformance tests
davidalger 1ab6e6c
Merge branch 'main' into algerdev/graceful-pod-termination
davidalger ac5bac1
Integrate with latest from main
davidalger 8cdc14f
Describe node used in test runs
davidalger 0c543b6
Use TAG=latest for conformance tests
davidalger b3dcffd
Update shutdown/ready logic and misc cleanup
davidalger c6bc7fb
Shutdown manager config test
davidalger 2ffd947
Test coverage FileLogger
davidalger cf106fa
Require use of patch field to override config on shutdown-manager con…
davidalger ae829d0
Merge branch 'main' into algerdev/graceful-pod-termination
davidalger f06cc01
Update docs
davidalger fb4e3ed
Remove knob for ExitAtConnections
davidalger f1b4be4
Pass image version for shutdown-manager in from build
davidalger 24f9484
Fix generated content
davidalger 0c701bd
Recombine image consts
davidalger eafa8a5
Lower default min-drain-duration to 5 seconds
davidalger 7696402
Update generated docs
davidalger 3a5071a
Merge branch 'main' into algerdev/graceful-pod-termination
davidalger f249d73
Fail health checks to support fast failure when active health checking
davidalger fa9bcd3
Update tests
davidalger 013099d
Merge branch 'main' into algerdev/graceful-pod-termination
davidalger afcbf23
Move drain type config to correct place
davidalger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| // Copyright Envoy Gateway Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // The full text of the Apache license is available in the LICENSE file at | ||
| // the root of the repo. | ||
|
|
||
| package cmd | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| "github.com/spf13/cobra" | ||
|
|
||
| "github.com/envoyproxy/gateway/internal/cmd/envoy" | ||
| ) | ||
|
|
||
| // getEnvoyCommand returns the envoy cobra command to be executed. | ||
| func getEnvoyCommand() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "envoy", | ||
| Short: "Envoy proxy management", | ||
| } | ||
|
|
||
| cmd.AddCommand(getShutdownCommand()) | ||
| cmd.AddCommand(getShutdownManagerCommand()) | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| // getShutdownCommand returns the shutdown cobra command to be executed. | ||
| func getShutdownCommand() *cobra.Command { | ||
| var drainTimeout time.Duration | ||
| var minDrainDuration time.Duration | ||
| var exitAtConnections int | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "shutdown", | ||
| Short: "Gracefully drain open connections prior to pod shutdown.", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return envoy.Shutdown(drainTimeout, minDrainDuration, exitAtConnections) | ||
| }, | ||
| } | ||
|
|
||
| cmd.PersistentFlags().DurationVar(&drainTimeout, "drain-timeout", 600*time.Second, | ||
| "Graceful shutdown timeout. This should be less than the pod's terminationGracePeriodSeconds.") | ||
|
|
||
| cmd.PersistentFlags().DurationVar(&minDrainDuration, "min-drain-duration", 5*time.Second, | ||
| "Minimum drain duration allowing time for endpoint deprogramming to complete.") | ||
|
|
||
| cmd.PersistentFlags().IntVar(&exitAtConnections, "exit-at-connections", 0, | ||
| "Number of connections to wait for when monitoring Envoy listener drain process.") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
||
| // getShutdownManagerCommand returns the shutdown manager cobra command to be executed. | ||
| func getShutdownManagerCommand() *cobra.Command { | ||
| var readyTimeout time.Duration | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "shutdown-manager", | ||
| Short: "Provides HTTP endpoint used in preStop hook to block until ready for pod shutdown.", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return envoy.ShutdownManager(readyTimeout) | ||
| }, | ||
| } | ||
|
|
||
| cmd.PersistentFlags().DurationVar(&readyTimeout, "ready-timeout", 610*time.Second, | ||
| "Shutdown ready timeout. This should be greater than shutdown's drain-timeout and less than the pod's terminationGracePeriodSeconds.") | ||
|
|
||
| return cmd | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need
MinDrainDuration&ExitAtConnectionsin the first iteration ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
ExitAtConnectionsin fb4e3ed butMinDrainDurationreally should stay. It's an important knob that should be configurable. I will be using it when rolling this out to infra I manage, and it's being used intest/config/gatewayclass.yamlto prevent a conservative default of 15 seconds from slowing CI processes.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate a little more on the endpoint deprogramming part ? this timeout is added to ensure the proxy's IP is removed from kube-proxy or other external loadbalancers ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this value is present to deal with eventual consistency of the various distributed networking components, prefer if we dropped this to 5s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what it's for. I've lowered the default to 5s