Skip to content

Commit

Permalink
fix: Limit github hooks manager daemon lifetime to 10 min (#1930)
Browse files Browse the repository at this point in the history
* fix: Start github hooks manager daemon only when DeleteHookOnFinish is enabled

Signed-off-by: Ivan Babiankou <[email protected]>
  • Loading branch information
ibabiankou authored and whynowy committed Jun 9, 2022
1 parent 11c547f commit 52a2620
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions eventsources/sources/github/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,11 @@ func (el *EventListener) StartListening(ctx context.Context, dispatch func([]byt
// and old pod terminates, if DeleteHookOnFinish is true, the hook will be deleted from github.
// This is a workaround to mitigate the race conditions.
logger.Info("starting github hooks manager daemon")
ticker := time.NewTicker(60 * time.Second)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
logger.Info("exiting github hooks manager daemon")
return
case <-ticker.C:
f()
}
for i := 0; i < 10; i++ {
time.Sleep(60 * time.Second)
f()
}
logger.Info("exiting github hooks manager daemon")
}()
} else {
logger.Info("no need to create webhooks")
Expand Down

0 comments on commit 52a2620

Please sign in to comment.