projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
20200: Fix test typo
[arvados.git]
/
lib
/
controller
/
handler.go
diff --git
a/lib/controller/handler.go
b/lib/controller/handler.go
index 07e6514810f97ceb691be7f9c528fd5560694d66..5d6bd9570c813e0f2eb7c721d0b5e02648fb452d 100644
(file)
--- a/
lib/controller/handler.go
+++ b/
lib/controller/handler.go
@@
-135,6
+135,7
@@
func (h *Handler) setup() {
hs := http.NotFoundHandler()
hs = prepend(hs, h.proxyRailsAPI)
hs := http.NotFoundHandler()
hs = prepend(hs, h.proxyRailsAPI)
+ hs = prepend(hs, h.limitLogCreateRequests)
hs = h.setupProxyRemoteCluster(hs)
hs = prepend(hs, oidcAuthorizer.Middleware)
mux.Handle("/", hs)
hs = h.setupProxyRemoteCluster(hs)
hs = prepend(hs, oidcAuthorizer.Middleware)
mux.Handle("/", hs)
@@
-152,11
+153,6
@@
func (h *Handler) setup() {
if logCreateLimit == 0 && h.Cluster.API.LogCreateRequestFraction > 0 {
logCreateLimit = 1
}
if logCreateLimit == 0 && h.Cluster.API.LogCreateRequestFraction > 0 {
logCreateLimit = 1
}
- if logCreateLimit == 0 {
- // can't have unlimited size channels, so just make
- // the buffer size really big.
- logCreateLimit = 4096
- }
h.limitLogCreate = make(chan struct{}, logCreateLimit)
h.proxy = &proxy{
h.limitLogCreate = make(chan struct{}, logCreateLimit)
h.proxy = &proxy{
@@
-195,11
+191,11
@@
func (h *Handler) localClusterRequest(req *http.Request) (*http.Response, error)
}
func (h *Handler) limitLogCreateRequests(w http.ResponseWriter, req *http.Request, next http.Handler) {
}
func (h *Handler) limitLogCreateRequests(w http.ResponseWriter, req *http.Request, next http.Handler) {
- if req.Method == http.MethodPost && strings.HasPrefix(req.URL.Path, "/arvados/v1/logs") {
+ if
cap(h.limitLogCreate) > 0 &&
req.Method == http.MethodPost && strings.HasPrefix(req.URL.Path, "/arvados/v1/logs") {
select {
case h.limitLogCreate <- struct{}{}:
select {
case h.limitLogCreate <- struct{}{}:
+ defer func() { <-h.limitLogCreate }()
next.ServeHTTP(w, req)
next.ServeHTTP(w, req)
- <-h.limitLogCreate
default:
http.Error(w, "Excess log messages", http.StatusServiceUnavailable)
}
default:
http.Error(w, "Excess log messages", http.StatusServiceUnavailable)
}