From 657994bdbfc0c43f16d54ccb4bb45d2c8fa8aad1 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 15 Apr 2021 12:24:31 +0200 Subject: [PATCH 1/4] migration: github: if rate limit is not enabled, ignore it --- modules/migrations/github.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index cb61086b2ad6b..0cd7d8f5349b5 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -130,8 +130,13 @@ func (g *GithubDownloaderV3) sleep() { // RefreshRate update the current rate (doesn't count in rate limit) func (g *GithubDownloaderV3) RefreshRate() error { - rates, _, err := g.client.RateLimits(g.ctx) + rates, resp, err := g.client.RateLimits(g.ctx) if err != nil { + // if rate limit is not enabled, ignore it + if resp != nil && resp.StatusCode == http.StatusNotFound { + g.rate = &github.Rate{} + return nil + } return err } From 1004612022f9b13f6aa7a2a709330b28871f2c5f Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 15 Apr 2021 12:46:10 +0200 Subject: [PATCH 2/4] use nil --- modules/migrations/github.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index 0cd7d8f5349b5..5150ea2560fdb 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -134,7 +134,7 @@ func (g *GithubDownloaderV3) RefreshRate() error { if err != nil { // if rate limit is not enabled, ignore it if resp != nil && resp.StatusCode == http.StatusNotFound { - g.rate = &github.Rate{} + g.rate = nil return nil } return err From dc4ba4a27cddf65d482f228201d46e6fb8e139d5 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 15 Apr 2021 13:00:39 +0200 Subject: [PATCH 3/4] log nil response --- modules/migrations/github.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index 5150ea2560fdb..fd6b68a679d62 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -136,6 +136,8 @@ func (g *GithubDownloaderV3) RefreshRate() error { if resp != nil && resp.StatusCode == http.StatusNotFound { g.rate = nil return nil + } else { + log.Error("TEST: RefreshRate resp status is nil!") } return err } From 12e26f2f13e8a1d0d1d040b245435f81d801eac2 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Thu, 15 Apr 2021 13:09:37 +0200 Subject: [PATCH 4/4] next --- modules/migrations/github.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/migrations/github.go b/modules/migrations/github.go index fd6b68a679d62..282e3b4786151 100644 --- a/modules/migrations/github.go +++ b/modules/migrations/github.go @@ -130,14 +130,12 @@ func (g *GithubDownloaderV3) sleep() { // RefreshRate update the current rate (doesn't count in rate limit) func (g *GithubDownloaderV3) RefreshRate() error { - rates, resp, err := g.client.RateLimits(g.ctx) + rates, _, err := g.client.RateLimits(g.ctx) if err != nil { // if rate limit is not enabled, ignore it - if resp != nil && resp.StatusCode == http.StatusNotFound { + if strings.Contains(err.Error(), "404") { g.rate = nil return nil - } else { - log.Error("TEST: RefreshRate resp status is nil!") } return err }