mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #22270 from runcom/too-many-login
distribution: errors: do not retry if too many login attempts
This commit is contained in:
commit
4de672690c
5 changed files with 27 additions and 5 deletions
|
@ -89,7 +89,7 @@ func retryOnError(err error) error {
|
||||||
}
|
}
|
||||||
case errcode.Error:
|
case errcode.Error:
|
||||||
switch v.Code {
|
switch v.Code {
|
||||||
case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeUnsupported, errcode.ErrorCodeDenied:
|
case errcode.ErrorCodeUnauthorized, errcode.ErrorCodeUnsupported, errcode.ErrorCodeDenied, errcode.ErrorCodeTooManyRequests:
|
||||||
return xfer.DoNotRetry{Err: err}
|
return xfer.DoNotRetry{Err: err}
|
||||||
}
|
}
|
||||||
case *url.Error:
|
case *url.Error:
|
||||||
|
|
|
@ -49,7 +49,7 @@ clone git github.com/boltdb/bolt v1.2.0
|
||||||
clone git github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7
|
clone git github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7
|
||||||
|
|
||||||
# get graph and distribution packages
|
# get graph and distribution packages
|
||||||
clone git github.com/docker/distribution 467fc068d88aa6610691b7f1a677271a3fac4aac
|
clone git github.com/docker/distribution 9ec0d742d69f77caa4dd5f49ceb70c3067d39f30
|
||||||
clone git github.com/vbatts/tar-split v0.9.11
|
clone git github.com/vbatts/tar-split v0.9.11
|
||||||
|
|
||||||
# get desired notary commit, might also need to be updated in Dockerfile
|
# get desired notary commit, might also need to be updated in Dockerfile
|
||||||
|
|
|
@ -110,6 +110,7 @@ func (mb *configManifestBuilder) Build(ctx context.Context) (m distribution.Mani
|
||||||
ContainerConfig struct {
|
ContainerConfig struct {
|
||||||
Cmd []string
|
Cmd []string
|
||||||
} `json:"container_config,omitempty"`
|
} `json:"container_config,omitempty"`
|
||||||
|
Author string `json:"author,omitempty"`
|
||||||
ThrowAway bool `json:"throwaway,omitempty"`
|
ThrowAway bool `json:"throwaway,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +146,7 @@ func (mb *configManifestBuilder) Build(ctx context.Context) (m distribution.Mani
|
||||||
Parent: parent,
|
Parent: parent,
|
||||||
Comment: h.Comment,
|
Comment: h.Comment,
|
||||||
Created: h.Created,
|
Created: h.Created,
|
||||||
|
Author: h.Author,
|
||||||
}
|
}
|
||||||
v1Compatibility.ContainerConfig.Cmd = []string{img.History[i].CreatedBy}
|
v1Compatibility.ContainerConfig.Cmd = []string{img.History[i].CreatedBy}
|
||||||
if h.EmptyLayer {
|
if h.EmptyLayer {
|
||||||
|
|
|
@ -63,6 +63,19 @@ var (
|
||||||
Description: "Returned when a service is not available",
|
Description: "Returned when a service is not available",
|
||||||
HTTPStatusCode: http.StatusServiceUnavailable,
|
HTTPStatusCode: http.StatusServiceUnavailable,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// ErrorCodeTooManyRequests is returned if a client attempts too many
|
||||||
|
// times to contact a service endpoint.
|
||||||
|
ErrorCodeTooManyRequests = Register("errcode", ErrorDescriptor{
|
||||||
|
Value: "TOOMANYREQUESTS",
|
||||||
|
Message: "too many requests",
|
||||||
|
Description: `Returned when a client attempts to contact a
|
||||||
|
service too many times`,
|
||||||
|
// FIXME: go1.5 doesn't export http.StatusTooManyRequests while
|
||||||
|
// go1.6 does. Update the hardcoded value to the constant once
|
||||||
|
// Docker updates golang version to 1.6.
|
||||||
|
HTTPStatusCode: 429,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
var nextCode = 1000
|
var nextCode = 1000
|
||||||
|
|
|
@ -51,11 +51,18 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error {
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(body, &detailsErr)
|
err = json.Unmarshal(body, &detailsErr)
|
||||||
if err == nil && detailsErr.Details != "" {
|
if err == nil && detailsErr.Details != "" {
|
||||||
if statusCode == http.StatusUnauthorized {
|
switch statusCode {
|
||||||
|
case http.StatusUnauthorized:
|
||||||
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
|
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
|
||||||
}
|
// FIXME: go1.5 doesn't export http.StatusTooManyRequests while
|
||||||
|
// go1.6 does. Update the hardcoded value to the constant once
|
||||||
|
// Docker updates golang version to 1.6.
|
||||||
|
case 429:
|
||||||
|
return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
|
||||||
|
default:
|
||||||
return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)
|
return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(body, &errors); err != nil {
|
if err := json.Unmarshal(body, &errors); err != nil {
|
||||||
return &UnexpectedHTTPResponseError{
|
return &UnexpectedHTTPResponseError{
|
||||||
|
|
Loading…
Add table
Reference in a new issue