Merge pull request #15025 from stonezdj/2.2_fall_back_local

(cherry-pick) Fall back to local registry when upstream registry is not working
This commit is contained in:
stonezdj(Daojun Zhang) 2021-06-04 11:12:21 +08:00 committed by GitHub
commit e579545f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,7 +97,12 @@ func preCheck(ctx context.Context) (art lib.ArtifactInfo, p *models.Project, ctl
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)
}
})
}