Repository navigation
test: Pin the shutdown budget and the delayed close - #920
Merged
Merged
Conversation
The manager keeps serving for webhookShutdownDelay after SIGTERM, then stops with GracefulShutdownTimeout. Both must end inside terminationGracePeriodSeconds in config/manager/manager.yaml, or the kubelet kills the pod before it stops. TestShutdownFitsTheGracePeriod reads the grace period from the manifest and fails when the sum does not fit, or when the delay is zero. TestManagerStartsTheDelayedClose reads manager.go and fails when the command no longer starts CloseConnectionsThenStop in its own goroutine, with the signal, webhookShutdownDelay and the manager's cancel function.
ecv
approved these changes
Nov 18, 2026
ecv
left a comment
Contributor
There was a problem hiding this comment.
Approve.
This closes the follow-up from #919. TestShutdownFitsTheGracePeriod reads terminationGracePeriodSeconds from the manager Deployment, so changing the delay, the timeout or the manifest past the 45s budget fails. TestManagerStartsTheDelayedClose parses manager.go and requires one go ...CloseConnectionsThenStop(signal, webhookShutdownDelay, cancel), so dropping the line or reordering its arguments fails. A missing grace period, or no Deployment running the manager, fails loudly rather than passing.
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.
Summary
#919 makes the manager keep serving for 10 seconds after SIGTERM, then stop with a graceful shutdown of at most 30 seconds, inside a grace period of 45 seconds. In the review of #919, ecv found that no test guards this wiring: a deleted delayed close, or other values for the delay, the timeout or the grace period, leave every test green. This PR adds two tests in
internal/cmd/manager/shutdown_test.go, and changes no other file.Design choices
manager.go. The wiring is inline in the command'sRunE, and a test cannot run that without a cluster. A behaviour test would need the wiring in a function of its own, which is a change to production code. I kept this PR to tests only. This package already reads Go source in a test (manager_test.go), and so doesinternal/agent(catalog_test.go).Evidence
Before: I broke the wiring in eight ways, one at a time. Each one fails a test:
terminationGracePeriodSeconds: 40TestShutdownFitsTheGracePeriod: "40s" is not less than "40s"managerGracefulShutdownTimeout = 40 * time.SecondTestShutdownFitsTheGracePeriod: "50s" is not less than "45s"webhookShutdownDelay = 0TestShutdownFitsTheGracePeriod: "0" is not positivectx := ctrl.SetupSignalHandler(), no delayed closeTestManagerStartsTheDelayedClose: nocontext.WithCancelgo ... CloseConnectionsThenStop(...)line deleted, its two names kept in useTestManagerStartsTheDelayedClose: no delayed closegoTestManagerStartsTheDelayedClose: no delayed closetime.Secondin place ofwebhookShutdownDelayTestManagerStartsTheDelayedClose: the arguments differstopManagerTestManagerStartsTheDelayedClose: the arguments differA deletion of only the
go ... CloseConnectionsThenStop(...)line already breaks the build, becauseshutdownandstopManagerare then unused. So the rows above use forms that compile.After: both tests pass.
make test,make lintandmake verify-generatedpass on this head.Watch: this PR changes no code that runs in a cluster, so no metric can show it. The one read is the
ci / Build and testcheck on this PR, which runs both tests.Merge Danger
Door: two-way
The PR adds one test file and changes no production code.
Blast Radius: tests
A later change to the shutdown values or to the wiring in
manager.gomust keep both tests green, or change them with it.Related to #709