mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-16 07:05:14 +00:00
cli: don't fail if rate limit is exceeded
Don't fail if rate limit is exceeded since this is a limitation/restriction of Github not a problem in the host. Print a warning when the rate limit is exceeded. For more information about Github's rate limit, see https://developer.github.com/v3/#rate-limiting Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
parent
b8716d8eec
commit
cb684cf8ea
@ -6,6 +6,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -276,12 +277,17 @@ func getReleases(releaseURL string, includeAll bool) ([]semver.Version, map[stri
|
||||
|
||||
releasesArray := []map[string]interface{}{}
|
||||
|
||||
bytes, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to read release details: %v", err)
|
||||
} else if resp.StatusCode == http.StatusForbidden && bytes.Contains(body, []byte("limit exceeded")) {
|
||||
// Do not fail if rate limit is exceeded
|
||||
kataLog.WithField("url", releaseURL).
|
||||
Warn("API rate limit exceeded. Try again later. Read https://docs.github.com/apps/building-github-apps/understanding-rate-limits-for-github-apps for more information")
|
||||
return []semver.Version{}, map[string]releaseDetails{}, nil
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(bytes, &releasesArray); err != nil {
|
||||
if err := json.Unmarshal(body, &releasesArray); err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to unpack release details: %v", err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user