Skip to content

Commit

Permalink
Added SIGTERM signal handling for graceful shutdown of Litmus-Checker (
Browse files Browse the repository at this point in the history
…#376)

* Added SIGTERM signal handling in checker

Signed-off-by: Jonsy13 <[email protected]>
  • Loading branch information
Jonsy13 authored Jun 19, 2023
1 parent 5fb73d5 commit c1bf5dd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions custom/litmus-checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ import (
"flag"
"io/ioutil"
"log"
"os"
"os/signal"
"syscall"

chaos_checker "github.com/gdsoumya/resourceChecker/pkg/chaos-checker"
"github.com/gdsoumya/resourceChecker/pkg/k8s"
"github.com/gdsoumya/resourceChecker/pkg/util"
)

func main() {
signalChannel := make(chan os.Signal)
signal.Notify(signalChannel, os.Interrupt, syscall.SIGTERM)
kubeconfig := flag.String("kubeconfig", "", "absolute path to the kubeconfig file")
file := flag.String("file", "", "absolute path to the chaosengine yaml")
engineFile := flag.String("saveName", "", "absolute path to the output file")
Expand Down Expand Up @@ -41,6 +46,14 @@ func main() {
Namespace: resp.GetNamespace(),
Selectors: "",
}

// Required, While aborting a Chaos Experiment, wait-container (argo-exec) sends SIGTERM signal to other (main) containers for aborting Argo-Workflow Pod
go func() {
<-signalChannel
log.Print("SIGTERM SIGNAL RECEIVED, Shutting down litmus-checker...")
os.Exit(0)
}()

log.Print("Created Resource Details: \n", resDef)
chaos_checker.CheckChaos(kubeconfig, resDef)
}

0 comments on commit c1bf5dd

Please sign in to comment.