From 33f16a55ba2b4b0854fecbaf3739e81b81d4182d Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Thu, 17 Apr 2025 14:15:12 +0200 Subject: [PATCH] etcd: fix 5 second delay during shutdown The main goroutine always waited for the background goroutine, which itself only proceeded after the 5 second timeout. To tell the goroutine that it is okay to stop immediately, the main goroutine must cancel the context as soon as etcd has quit. --- test/integration/framework/etcd.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/integration/framework/etcd.go b/test/integration/framework/etcd.go index 9f2f4b943c2..4999dd1bca3 100644 --- a/test/integration/framework/etcd.go +++ b/test/integration/framework/etcd.go @@ -153,15 +153,17 @@ func RunCustomEtcd(dataDir string, customFlags []string, output io.Writer) (url defer wg.Done() select { case <-ctx.Done(): - klog.Infof("etcd exited gracefully, context cancelled") + klog.V(6).InfoS("etcd exited gracefully, context cancelled") case <-time.After(5 * time.Second): klog.Infof("etcd didn't exit in 5 seconds, killing it") cancel() } }() err := cmd.Wait() + klog.V(2).InfoS("etcd exited", "err", err) + // Tell goroutine that we are done. + cancel() wg.Wait() - klog.Infof("etcd exit status: %v", err) err = os.RemoveAll(etcdDataDir) if err != nil { klog.Warningf("error during etcd cleanup: %v", err)