mirror of
https://github.com/openfaas/faas.git
synced 2025-06-18 12:06:37 +00:00
Feature for probing functions
Introduces a single-flight call to a function's health endpoint to verify that it is registered with an Istio sidecar (Envoy) before letting the invocation through. Results are cached for 5 seconds, before a probe is required again. Tested without Istio, with probe_functions environment variable set to true, I saw a probe execute in the logs. Fixes: #1721 for Istio users. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
committed by
Alex Ellis
parent
01841f605c
commit
88eea5f62e
@ -10,6 +10,8 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/openfaas/faas/gateway/pkg/middleware"
|
||||
)
|
||||
|
||||
func Test_buildUpstreamRequest_Body_Method_Query(t *testing.T) {
|
||||
@ -170,7 +172,7 @@ func Test_getServiceName(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
service := getServiceName(u.Path)
|
||||
service := middleware.GetServiceName(u.Path)
|
||||
if service != s.serviceName {
|
||||
t.Fatalf("Incorrect service name - want: %s, got: %s", s.serviceName, service)
|
||||
}
|
||||
@ -195,7 +197,7 @@ func Test_buildUpstreamRequest_WithPathNoQuery(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
transformer := FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformer := middleware.FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformedPath := transformer.Transform(request)
|
||||
|
||||
wantTransformedPath := functionPath
|
||||
@ -251,7 +253,7 @@ func Test_buildUpstreamRequest_WithNoPathNoQuery(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
transformer := FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformer := middleware.FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformedPath := transformer.Transform(request)
|
||||
|
||||
wantTransformedPath := "/"
|
||||
@ -305,7 +307,7 @@ func Test_buildUpstreamRequest_WithPathAndQuery(t *testing.T) {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
transformer := FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformer := middleware.FunctionPrefixTrimmingURLPathTransformer{}
|
||||
transformedPath := transformer.Transform(request)
|
||||
|
||||
wantTransformedPath := functionPath
|
||||
|
Reference in New Issue
Block a user