mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
When StartTestServer is called with a TContext by the caller, tearing down the apiserver via its tear-down function would also cancel the context for everyone else using it, which is unexpected and not intended. Accidentally, scheduler_perf and scheduler/batch relied on this behavior: - The apiserver clients waited on a context that got its cancellation from the root context and thus gets canceled last. - The apiserver was told to stop earlier, but then waited because it still had active clients. - Shutdown gets slowed down enough that integration testing times out. The fix is to explicitly cancel the clients before the apiserver. Long-term ktesting should be changed to do the same as the new testing.T.Context: cancel the context *before* cleaning up, not *after* it.