Skip to content

Commit a6a3f4c

Browse files
committed
Add X-OpenFaaS-Internal to internal HTTP errors
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]>
1 parent 243c501 commit a6a3f4c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

executor/http_runner.go

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
148148
// Error unrelated to context / deadline
149149
if reqCtx.Err() == nil {
150150
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", time.Since(startedTime).Seconds()))
151+
w.Header().Add("X-OpenFaaS-Internal", "of-watchdog")
151152

152153
w.WriteHeader(http.StatusInternalServerError)
153154

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

164166
w.WriteHeader(http.StatusGatewayTimeout)
165167
return nil
166168
}
167169

168170
w.Header().Set("X-Duration-Seconds", fmt.Sprintf("%f", time.Since(startedTime).Seconds()))
171+
w.Header().Add("X-OpenFaaS-Internal", "of-watchdog")
172+
169173
w.WriteHeader(http.StatusInternalServerError)
170174
return err
171175
}

0 commit comments

Comments
 (0)