Skip to content

Commit

Permalink
fix: close piper if watcher down
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaDo committed Jan 11, 2025
1 parent d869b7c commit 399a7e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/piper/piper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ func main() {
// Create context that listens for the interrupt signal from the OS.
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
event_handler.Start(ctx, cfg, globalClients)
event_handler.Start(ctx, stop, cfg, globalClients)
server.Start(ctx, stop, cfg, globalClients)
}
3 changes: 2 additions & 1 deletion pkg/event_handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"log"
)

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

0 comments on commit 399a7e6

Please sign in to comment.