resolver: avoid retrying fatal error

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-08-11 19:08:41 -07:00
parent 8f8dccf837
commit e322304c07
1 changed files with 10 additions and 0 deletions

View File

@ -148,7 +148,17 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R
if c.Scheme == auth.BearerAuth {
if err := invalidAuthorization(c, responses); err != nil {
a.handlers.delete(handler)
oldScope := ""
if handler != nil {
oldScope = strings.Join(handler.common.Scopes, " ")
}
handler = nil
// this hacky way seems to be best method to detect that error is fatal and should not be retried with a new token
if c.Parameters["error"] == "insufficient_scope" && c.Parameters["scope"] == oldScope {
return err
}
}
// reuse existing handler