Pix4D / cogito

Concourse resource for GitHub Commit Status and Google Chat notifications
MIT License
35 stars 14 forks source link

retry GitHub HTTP request when rate limited: does not sleep when it should #132

Closed marco-m-pix4d closed 11 months ago

marco-m-pix4d commented 11 months ago

We detect the situation correctly, we calculate the correct time to sleep, we log that we will sleep but actually we do NOT sleep, thus we consume the 3 attempts one after the other and finally fail:

[INFO]  cogito: This is the Cogito GitHub status resource. Tag: 0.10.2, commit: d8221ad, build date: 2023-07-28
[INFO]  cogito.put.gChat: not sending to chat: reason="feature not enabled"
[INFO]  cogito.put.ghCommitStatus: GitHub HTTP request: attempt=1 max=3
[INFO]  cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"
[INFO]  cogito.put.ghCommitStatus: GitHub HTTP request: attempt=2 max=3
[INFO]  cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"
[INFO]  cogito.put.ghCommitStatus: GitHub HTTP request: attempt=3 max=3
[INFO]  cogito.put.ghCommitStatus: Sleeping for: duration=7m42s reason="rate limited, should retry"

cogito: error: put: failed to add state "pending" for commit XXX: 403 Forbidden
Body: {"message":"API rate limit exceeded for user ID YYY.","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}
Hint: Rate limited but the wait time to reset would be longer than 15m0s (MaxSleepTime)

This has been introduced by #128

😿