mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
hack/e2e.go: listen for Interrupt signal and attempt cleanup if using --down
Signed-off-by: Jess Frazelle <me@jessfraz.com> Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
parent
41f17bd9ac
commit
da786a8dc5
16
hack/e2e.go
16
hack/e2e.go
@ -25,6 +25,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -159,6 +160,21 @@ func main() {
|
|||||||
log.Fatalf("Error creating deployer: %v", err)
|
log.Fatalf("Error creating deployer: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *down {
|
||||||
|
// listen for signals such as ^C and gracefully attempt to clean up
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, os.Interrupt)
|
||||||
|
go func() {
|
||||||
|
for range c {
|
||||||
|
log.Print("Captured ^C, gracefully attempting to cleanup resources..")
|
||||||
|
if err := deploy.Down(); err != nil {
|
||||||
|
log.Printf("Tearing down deployment failed: %v", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
if err := run(deploy); err != nil {
|
if err := run(deploy); err != nil {
|
||||||
log.Fatalf("Something went wrong: %s", err)
|
log.Fatalf("Something went wrong: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user