From 00516ba2f49963087ef9cbeda26b55fbbd6b7dd6 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 8 Mar 2022 12:43:05 +0000 Subject: [PATCH] Retry release notes after a few seconds I have been seeing the error "unable to detect release" due to a timing issue between the webhook and GitHub's API updating current releases. This enables a single retry and I'll monitor it from there. Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- derek.yml | 4 ++-- main.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/derek.yml b/derek.yml index 3be02f7..5aaa519 100644 --- a/derek.yml +++ b/derek.yml @@ -3,9 +3,9 @@ provider: gateway: http://127.0.0.1:8080 functions: - derek-0110: + derek-0113: handler: ./ - image: ghcr.io/alexellis/derek:0.11.0 + image: ghcr.io/alexellis/derek:0.11.3 lang: dockerfile environment: debug: true diff --git a/main.go b/main.go index 2695402..82369d3 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "log" "net/http" "os" + "time" "github.com/google/go-github/github" @@ -238,6 +239,15 @@ func handleEvent(eventType string, bytesIn []byte, config config.Config) error { handler := handler.NewReleaseHandler(config, int(req.Installation.GetID())) err = handler.Handle(req) + // retry once - with a 5 second delay + if err != nil && err.Error() == "unable to detect current release, retry webhook after a few seconds" { + time.Sleep(time.Second * 5) + err = handler.Handle(req) + if err != nil { + err = fmt.Errorf("got an error, then retried after 5 seconds: %w", err) + } + + } } return err }