usage-metrics-collector
usage-metrics-collector copied to clipboard
use blocking function to shut down etcd/apiserver
While using testutil.TestDir
in a project to run unit tests against a local kube-apiserver, I noticed that I was building up orphaned etcd and kube-apiserver processes on each test run. This seems to be because the use of context to signal a shutdown in SetupEnvTest doesn't block the exit of the go process, thus fails to process environment.Stop()
. The simple solution seemed to be to just send an anonymous function back as the cancel function, rather than the context cancel function.
Tested locally to confirm that unit tests depending on this still ran successfully, and no etcd/kube-apiserver processes were left behind.