Skip to content

Commit

Permalink
Retry release notes after a few seconds
Browse files Browse the repository at this point in the history
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) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Mar 8, 2022
1 parent e4330ca commit 00516ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions derek.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"net/http"
"os"
"time"

"github.com/google/go-github/github"

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 00516ba

Please sign in to comment.