Skip to content

Commit

Permalink
Add X-OpenFaaS-Internal to internal HTTP errors
Browse files Browse the repository at this point in the history
For timeouts and internal server errors, no additional header
was being added to differentiate between the handler and the
watchdog itself.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Jul 12, 2024
1 parent 243c501 commit a6a3f4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions executor/http_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
// Error unrelated to context / deadline
if reqCtx.Err() == nil {
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", time.Since(startedTime).Seconds()))
w.Header().Add("X-OpenFaaS-Internal", "of-watchdog")

w.WriteHeader(http.StatusInternalServerError)

Expand All @@ -160,12 +161,15 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
// Error due to timeout / deadline
log.Printf("Upstream HTTP killed due to exec_timeout: %s\n", f.ExecTimeout)
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", time.Since(startedTime).Seconds()))
w.Header().Add("X-OpenFaaS-Internal", "of-watchdog")

w.WriteHeader(http.StatusGatewayTimeout)
return nil
}

w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", time.Since(startedTime).Seconds()))
w.Header().Add("X-OpenFaaS-Internal", "of-watchdog")

w.WriteHeader(http.StatusInternalServerError)
return err
}
Expand Down

0 comments on commit a6a3f4c

Please sign in to comment.