From c0c9f1f318c0038cdac2bb3e8a4c56dee2339efa Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Fri, 21 May 2021 15:04:16 +0200 Subject: [PATCH] Ignore first SIGINT in node-e2e tests Node e2e tests exceeding the global timeout are sent SIGINT, resulting in no artifacts or console output. This will ignore the first SIGINT, and since all children processes are being stopped due to SIGINT, we can clean up before exiting. --- test/e2e_node/runner/remote/run_remote.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/e2e_node/runner/remote/run_remote.go b/test/e2e_node/runner/remote/run_remote.go index 8224725417d..67d0972be0b 100644 --- a/test/e2e_node/runner/remote/run_remote.go +++ b/test/e2e_node/runner/remote/run_remote.go @@ -29,6 +29,7 @@ import ( "net/http" "os" "os/exec" + "os/signal" "path/filepath" "regexp" "sort" @@ -200,6 +201,20 @@ func main() { klog.Fatalf("--test-suite must be one of default, cadvisor, or conformance") } + // Listen for SIGINT and ignore the first one. In case SIGINT is sent to this + // process and all its children, we ignore it here, while our children ssh connections + // are stopped. This allows us to gather artifacts and print out test state before + // being killed. + c := make(chan os.Signal) + signal.Notify(c, os.Interrupt) + go func() { + <-c + fmt.Printf("Received SIGINT. Will exit on next SIGINT.\n") + <-c + fmt.Printf("Received another SIGINT. Will exit.\n") + os.Exit(1) + }() + rand.Seed(time.Now().UnixNano()) if *buildOnly { // Build the archive and exit