Skip to content

Enable API server's watch termination grace period by default#7188

Merged
twz123 merged 1 commit into
k0sproject:mainfrom
twz123:watch-termination-grace-period
May 13, 2026
Merged

Enable API server's watch termination grace period by default#7188
twz123 merged 1 commit into
k0sproject:mainfrom
twz123:watch-termination-grace-period

Conversation

@twz123
Copy link
Copy Markdown
Member

@twz123 twz123 commented Mar 2, 2026

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@twz123 twz123 added enhancement New feature or request area/controlplane labels Mar 2, 2026
@twz123 twz123 marked this pull request as ready for review March 2, 2026 11:46
@twz123 twz123 requested review from a team as code owners March 2, 2026 11:46
@twz123 twz123 requested review from jnummelin and ncopa March 2, 2026 11:46
@twz123 twz123 added this to the 1.36 milestone 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>
@twz123 twz123 force-pushed the watch-termination-grace-period branch from 002c392 to adaa2c8 Compare April 27, 2026 14:24
@twz123 twz123 merged commit 222a994 into k0sproject:main May 13, 2026
206 of 208 checks passed
@twz123 twz123 deleted the watch-termination-grace-period branch May 13, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/controlplane enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants