Merge pull request #14949 from stonezdj/21may22_fallback_localregistry

Fall back to local registry when upstream registry is not working
This commit is contained in:
Wenkai Yin(尹文开) 2021-05-31 11:00:43 +08:00 committed by GitHub
commit 4ed5fee681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,7 +95,12 @@ func preCheck(ctx context.Context) (art lib.ArtifactInfo, p *proModels.Project,
func ManifestMiddleware() func(http.Handler) http.Handler {
return middleware.New(func(w http.ResponseWriter, r *http.Request, next http.Handler) {
if err := handleManifest(w, r, next); err != nil {
httpLib.SendError(w, err)
if errors.IsNotFoundErr(err) {
httpLib.SendError(w, err)
return
}
log.Errorf("failed to proxy manifest, fallback to local, request uri: %v, error: %v", r.RequestURI, err)
next.ServeHTTP(w, r)
}
})
}