mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Log requests returning TooManyRequests error
This commit is contained in:
		@@ -119,12 +119,16 @@ func MaxInFlightLimit(c chan bool, longRunningRequestCheck LongRunningRequestChe
 | 
				
			|||||||
			defer func() { <-c }()
 | 
								defer func() { <-c }()
 | 
				
			||||||
			handler.ServeHTTP(w, r)
 | 
								handler.ServeHTTP(w, r)
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			tooManyRequests(w)
 | 
								tooManyRequests(r, w)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func tooManyRequests(w http.ResponseWriter) {
 | 
					func tooManyRequests(req *http.Request, w http.ResponseWriter) {
 | 
				
			||||||
 | 
						// "Too Many Requests" response is returned before logger is setup for the request.
 | 
				
			||||||
 | 
						// So we need to explicitly log it here.
 | 
				
			||||||
 | 
						defer httplog.NewLogged(req, &w).Log()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Return a 429 status indicating "Too Many Requests"
 | 
						// Return a 429 status indicating "Too Many Requests"
 | 
				
			||||||
	w.Header().Set("Retry-After", RetryAfter)
 | 
						w.Header().Set("Retry-After", RetryAfter)
 | 
				
			||||||
	http.Error(w, "Too many requests, please try again later.", errors.StatusTooManyRequests)
 | 
						http.Error(w, "Too many requests, please try again later.", errors.StatusTooManyRequests)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user