internal/teeproxy: don't tee expected 404s

Don't tee requests that we expect to 404 on pkg.go.dev, since this makes
the logs noisy and the information isn't useful.

Change-Id: I01217a2a99c943bb1e8639ee00ff0f00d29d53d1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/257971
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Trust: Julie Qiu <julie@golang.org>
This commit is contained in:
Julie Qiu 2020-09-28 17:22:10 -04:00
Родитель 40c700a80f
Коммит 197e3b6957
1 изменённых файлов: 42 добавлений и 19 удалений

Просмотреть файл

@ -74,25 +74,33 @@ type RequestEvent struct {
}
var gddoToPkgGoDevRequest = map[string]string{
"/": "/",
"/-/about": "/about",
"/-/bootstrap.min.css": "/404",
"/-/bootstrap.min.js": "/404",
"/-/bot": "/404",
"/-/go": "/std",
"/-/jquery-2.0.3.min.js": "/404",
"/-/refresh": "/404",
"/-/sidebar.css": "/404",
"/-/site.css": "/404",
"/-/subrepo": "/404",
"/BingSiteAuth.xml": "/404",
"/C": "/C",
"/favicon.ico": "/favicon.ico",
"/google3d2f3cd4cc2bb44b.html": "/404",
"/humans.txt": "/404",
"/robots.txt": "/404",
"/site.js": "/404",
"/third_party/jquery.timeago.js": "/404",
"/": "/",
"/-/about": "/about",
"/-/go": "/std",
"/C": "/C",
"/favicon.ico": "/favicon.ico",
}
// expected404s are a list of godoc.org URLs that we expected to 404 on
// pkg.go.dev.
var expected404s = map[string]bool{
"/-/bootstrap.min.css": true,
"/-/bootstrap.min.js": true,
"/-/bot": true,
"/-/jquery-2.0.3.min.js": true,
"/-/refresh": true,
"/-/sidebar.css": true,
"/-/site.css": true,
"/-/site.js": true,
"/BingSiteAuth.xml": true,
"/google3d2f3cd4cc2bb44b.html": true,
"/humans.txt": true,
"/robots.txt": true,
"/third_party/jquery.timeago.js": true,
// TODO: add a replacement page for this before redirecting godoc.org
// traffic.
"/-/subrepo": true,
}
// statusRedBreaker is a custom HTTP status code that denotes that a request
@ -268,6 +276,21 @@ func (s *Server) doRequest(r *http.Request) (results map[string]*RequestEvent, s
results = map[string]*RequestEvent{
"godoc.org": gddoEvent,
}
if _, ok := expected404s[gddoEvent.Path]; ok {
// Don't tee these requests, since we know they will 404.
return results, http.StatusOK, nil
}
for _, s := range []string{
"?import-graph",
"?status.png",
"?status.svg",
"api.godoc.org",
} {
if strings.Contains(gddoEvent.URL, s) {
// Don't tee these requests, since we know they will 404.
return results, http.StatusOK, nil
}
}
if len(s.hosts) > 0 {
rateLimited := !s.limiter.Allow()
for _, host := range s.hosts {