Skip to content

Commit 399a7e6

Browse files
committed
fix: close piper if watcher down
1 parent d869b7c commit 399a7e6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmd/piper/piper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ func main() {
5151
// Create context that listens for the interrupt signal from the OS.
5252
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
5353
defer stop()
54-
event_handler.Start(ctx, cfg, globalClients)
54+
event_handler.Start(ctx, stop, cfg, globalClients)
5555
server.Start(ctx, stop, cfg, globalClients)
5656
}

pkg/event_handler/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"log"
99
)
1010

11-
func Start(ctx context.Context, cfg *conf.GlobalConfig, clients *clients.Clients) {
11+
func Start(ctx context.Context, stop context.CancelFunc, cfg *conf.GlobalConfig, clients *clients.Clients) {
1212
labelSelector := &metav1.LabelSelector{
1313
MatchExpressions: []metav1.LabelSelectorRequirement{
1414
{Key: "piper.quickube.com/notified",
@@ -37,6 +37,7 @@ func Start(ctx context.Context, cfg *conf.GlobalConfig, clients *clients.Clients
3737
if !ok {
3838
log.Print("[event handler] result channel closed")
3939
watcher.Stop()
40+
stop()
4041
return
4142
}
4243
if err2 := handler.Handle(ctx, &event); err2 != nil {

0 commit comments

Comments
 (0)