From a6a3f4cb23f33b7c359d5b0309b7ae1da2df95ba Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Fri, 12 Jul 2024 18:13:53 +0100 Subject: [PATCH] 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) --- executor/http_runner.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/executor/http_runner.go b/executor/http_runner.go index b9493f9..d114379 100644 --- a/executor/http_runner.go +++ b/executor/http_runner.go @@ -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) @@ -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 }