mirror of https://github.com/portainer/portainer
Fix dockerhub pro account rate-limit issue (#5352)
parent
c943ac498f
commit
cee7ac26e9
|
@ -132,8 +132,18 @@ func getDockerHubLimits(httpClient *client.HTTPClient, token string) (*dockerhub
|
||||||
return nil, errors.New("failed fetching dockerhub limits")
|
return nil, errors.New("failed fetching dockerhub limits")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An error with rateLimit-Limit or RateLimit-Remaining is likely for dockerhub pro accounts where there is no rate limit.
|
||||||
|
// In that specific case the headers will not be present. Don't bubble up the error as its normal
|
||||||
|
// See: https://docs.docker.com/docker-hub/download-rate-limit/
|
||||||
rateLimit, err := parseRateLimitHeader(resp.Header, "RateLimit-Limit")
|
rateLimit, err := parseRateLimitHeader(resp.Header, "RateLimit-Limit")
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
rateLimitRemaining, err := parseRateLimitHeader(resp.Header, "RateLimit-Remaining")
|
rateLimitRemaining, err := parseRateLimitHeader(resp.Header, "RateLimit-Remaining")
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
return &dockerhubStatusResponse{
|
return &dockerhubStatusResponse{
|
||||||
Limit: rateLimit,
|
Limit: rateLimit,
|
||||||
|
|
|
@ -32,7 +32,7 @@ export default class porImageRegistryContainerController {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.pullRateLimits = await this.DockerHubService.checkRateLimits(this.endpoint, this.registryId || 0);
|
this.pullRateLimits = await this.DockerHubService.checkRateLimits(this.endpoint, this.registryId || 0);
|
||||||
this.setValidity(this.pullRateLimits.remaining >= 0);
|
this.setValidity(!this.pullRateLimits.limit || (this.pullRateLimits.limit && this.pullRateLimits.remaining >= 0));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error('Failed loading DockerHub pull rate limits', e);
|
console.error('Failed loading DockerHub pull rate limits', e);
|
||||||
|
|
Loading…
Reference in New Issue