router

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FORWARDED represents the 'Forwarded' request header
	FORWARDED = "Forwarded"

	// X_FORWARDED_HOST represents the 'X_FORWARDED_HOST' request header
	X_FORWARDED_HOST = "X-Forwarded-Host"
)
View Source
const (
	// HEADERS_FISSION_FUNCTION_PREFIX represents a function prefix request header
	HEADERS_FISSION_FUNCTION_PREFIX = "Fission-Function"
)

Variables

This section is empty.

Functions

func Start

func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger *zap.Logger, mgr manager.Interface, port int, executor eclient.ClientInterface) error

Start starts a router

Types

type AuthConf added in v1.16.0

type AuthConf struct {
	// contains filtered or unexported fields
}

type HTTPTriggerSet

type HTTPTriggerSet struct {
	// contains filtered or unexported fields
}

HTTPTriggerSet represents an HTTP trigger set

func (HTTPTriggerSet) ServeHTTP

func (mr HTTPTriggerSet) ServeHTTP(responseWriter http.ResponseWriter, request *http.Request)

type RetryingRoundTripper

type RetryingRoundTripper struct {
	// contains filtered or unexported fields
}

RetryingRoundTripper is a layer on top of http.DefaultTransport, with retries.

func (*RetryingRoundTripper) RoundTrip

func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is a custom transport with retries for http requests that forwards the request to the right serviceUrl, obtained from router's cache or from executor if router entry is stale.

It first checks if the service address for this function came from router's cache. If it didn't, it makes a request to executor to get a new service for function. If that succeeds, it adds the address to it's cache and makes a request to that address with transport.RoundTrip call. Initial requests to new k8s services sometimes seem to fail, but retries work. So, it retries with an exponential back-off for maxRetries times.

Else if it came from the cache, it makes a transport.RoundTrip with that cached address. If the response received is a network dial error (which means that the pod doesn't exist anymore), it removes the cache entry and makes a request to executor to get a new service for function. It then retries transport.RoundTrip with the new address.

At any point in time, if the response received from transport.RoundTrip is other than dial network error, it is relayed as-is to the user, without any retries.

While this RoundTripper handles the case where a previously cached address of the function pod isn't valid anymore (probably because the pod got deleted somehow), by making a request to executor to get a new service for this function, it doesn't handle a case where a newly specialized pod gets deleted just after the GetServiceForFunction succeeds. In such a case, the RoundTripper will retry requests against the new address and give up after maxRetries. However, the subsequent http call for this function will ensure the cache is invalidated.

If GetServiceForFunction returns an error or if RoundTripper exits with an error, it gets translated into 502 inside ServeHttp function of the reverseProxy. Earlier, GetServiceForFunction was called inside handler function and fission explicitly set http status code to 500 if it returned an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL