Enable API server's watch termination grace period by default#7188
Merged
Conversation
ncopa
approved these changes
Mar 11, 2026
By default, the API server doesn't terminate long-running watches during shutdown: Active watch traffic is subject to regular HTTP server shutdown behavior and will delay the shutdown until the overall HTTP request timeout is reached. Previously, k0s relied on a fixed supervisor stop timeout of five seconds, which did not account for this behavior under realistic load. Enable the API server's shutdown watch termination grace period by default so active watch streams are drained during shutdown. Since watch traffic accounts for most long-running API activity in normal clusters, this allows for generally faster API server shutdowns, aligning with k0s's requirement to promptly respond to shutdown requests from the init system. Derive the supervisor stop timeout from the API server flags, then clamp it to the range of 5 to 20 seconds to stay within the typical init system stop time budget. Set the watch termination grace period to the stop timeout minus two seconds, if not explicitly specified by the user. Finally, add a k0s controller command line flag to explicitly set the API server's stop timeout and bypass its automatic calculation. Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
002c392 to
adaa2c8
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
By default, the API server doesn't terminate long-running watches during shutdown: Active watch traffic is subject to regular HTTP server shutdown behavior and will delay the shutdown until the overall HTTP request timeout is reached. Previously, k0s relied on a fixed supervisor stop timeout of five seconds, which did not account for this behavior under realistic load.
Enable the API server's shutdown watch termination grace period by default so active watch streams are drained during shutdown. Since watch traffic accounts for most long-running API activity in normal clusters, this allows for generally faster API server shutdowns, aligning with k0s's requirement to promptly respond to shutdown requests from the init system.
Derive the supervisor stop timeout from the API server flags, then clamp it to the range of 5 to 20 seconds to stay within the typical init system stop time budget. Set the watch termination grace period to the stop timeout minus two seconds, if not explicitly specified by the user. Finally, add a k0s controller command line flag to explicitly set the API server's stop timeout and bypass its automatic calculation.
Type of change
How Has This Been Tested?
Checklist