Fix status code for rate limit (#1924)
Co-authored-by: Rahul Bhati <rjbhati009@gmail.com> Co-authored-by: Vishal <vishal-biyani@users.noreply.github.com>
This commit is contained in:
co-authored by
Rahul Bhati
Vishal
parent
e2376c27b4
commit
f28799cc4c
@@ -191,11 +191,9 @@ func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Re
|
||||
// We might want a specific error code or header for fission failures as opposed to
|
||||
// user function bugs.
|
||||
statusCode, errMsg := ferror.GetHTTPError(err)
|
||||
// if statusCode == http.StatusTooManyRequests {
|
||||
// time.Sleep(executingTimeout)
|
||||
// executingTimeout = executingTimeout * time.Duration(roundTripper.funcHandler.tsRoundTripperParams.timeoutExponent)
|
||||
// continue
|
||||
// } else {
|
||||
if statusCode == http.StatusTooManyRequests {
|
||||
return nil, err
|
||||
}
|
||||
if roundTripper.funcHandler.isDebugEnv {
|
||||
return &http.Response{
|
||||
StatusCode: statusCode,
|
||||
@@ -209,7 +207,7 @@ func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Re
|
||||
}, nil
|
||||
}
|
||||
return nil, ferror.MakeError(http.StatusInternalServerError, err.Error())
|
||||
// }
|
||||
|
||||
}
|
||||
if roundTripper.funcHandler.function.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType == fv1.ExecutorTypePoolmgr {
|
||||
defer func(fn *fv1.Function, serviceURL *url.URL) {
|
||||
@@ -558,7 +556,6 @@ func (fh functionHandler) getProxyErrorHandler(start time.Time, rrt *RetryingRou
|
||||
return func(rw http.ResponseWriter, req *http.Request, err error) {
|
||||
var status int
|
||||
var msg string
|
||||
|
||||
switch err {
|
||||
case context.Canceled:
|
||||
// 499 CLIENT CLOSED REQUEST
|
||||
@@ -573,14 +570,15 @@ func (fh functionHandler) getProxyErrorHandler(start time.Time, rrt *RetryingRou
|
||||
msg = "function not responses before the timeout"
|
||||
fh.logger.Error(msg, zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
||||
default:
|
||||
status = http.StatusBadGateway
|
||||
code, msg := ferror.GetHTTPError(err)
|
||||
status = code
|
||||
msg = "error sending request to function"
|
||||
fh.logger.Error(msg, zap.Error(err), zap.Any("function", fh.function), zap.Any("request_header", req.Header))
|
||||
fh.logger.Error(msg, zap.Error(err), zap.Any("function", fh.function), zap.Any("request_header", req.Header), zap.Any("code", code))
|
||||
}
|
||||
|
||||
go fh.collectFunctionMetric(start, rrt, req, &http.Response{
|
||||
StatusCode: status,
|
||||
ContentLength: 0,
|
||||
ContentLength: req.ContentLength,
|
||||
})
|
||||
|
||||
// TODO: return error message that contains traceable UUID back to user. Issue #693
|
||||
|
||||
Reference in New Issue
Block a user