75 Commits

Author SHA1 Message Date
Thomas E Lackey
decf9addb3 Make 'URLPathTransformer' interface and implementation to do the function prefix trimming instead of baking it in. Also add a configuration option, 'pass_url_path_to_functions' to control whether the full path is passed to the functions or not.
Signed-off-by: Thomas E Lackey <telackey@bozemanpass.com>
2018-08-29 12:41:04 +01:00
Thomas E Lackey
7870b87c38 Implement proposal 716, passing full paths through the Gateway and fwatchdog.
Previously, only the query string of the URL was passed through the Gateway.
With this change, the entire path requested by the client is passed through as well as the query string.

While fwatchdog already supported passing the path through, in practice this would not happen
since the Gateway would have swallowed it before forwarding the request to the watchdog.

With this change, the path portion after the function name is added to the Http_Path environment
variable, provided that cgiHeaders are enabled.  This is similar to the of-watchdog equivalent.

Signed-off-by: Thomas E Lackey <telackey@bozemanpass.com>
2018-08-29 12:41:04 +01:00
Ken Fukuyama
4fabd50799 Changed Metrics to be exposed via Exporter
This change exposes the gateway metrics with an exporter which
implements the Collector interface of prometheus.
This change Fixes #697

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-08-24 09:01:41 +01:00
Alex Ellis (VMware)
c86de503c7 Attach X-Call-Id to asynchronous calls
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-16 16:04:09 +01:00
Alex Ellis (VMware)
8f0d2d1fd6 Expose scale-function endpoint
- exposes scale-function endpoint for use with faas-idler, this
is protected by auth when enabled.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-23 15:24:11 +01:00
Alex Ellis (VMware)
9512f09d2b Refactor scaling to use existing code
Existing code has been used for scaling up and querying replicas.
This meant the new code was deleted and there is less duplication
now.

The cache store a whole query response rather than just the
available replica count and the tests were updated. This has been
tested with Docker swarm and the image:
 openfaas/gateway:scale-17-07-2018

This feature now needs the env-var of scale_from_zero to be enabled
in order to turn on the scaling behaviour.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-20 11:39:36 +01:00
Alex Ellis (VMware)
c58af8da56 Disable scaling from zero by default
This disables the scaling proxy by default since it is not the
default user-experience and is still under refinement.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-20 11:39:36 +01:00
Alex Ellis (VMware)
e67d45caa1 Add feature: scale from zero to 1 replicas
This change allows functions to be "idled" or scaled to zero
replicas and then be invoked later on. There is a penalty to
scaling up - the API gateway proxy will block until the function
is ready.

A cache is included to off-set the calls to upstream API to check
on readiness along with unit tests.

Testing via scaling to zero replicas and then invoking function.
On Swarm I observed 3 seconds on an Intel Nuc i5 for scaling back
from zero replicas.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-20 11:39:36 +01:00
Edward Wilde
aca2c7fe2a Enhance info endpoint to include gateway version
Extend the health endpoint and add gateway version information

Resolves: #733
Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-07-06 17:50:48 +01:00
Alex Ellis (VMware)
223c561706 Vendor new queue-worker version
Introduces 0.4.6 of queue-worker - see upstream repo for changes.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-06-18 20:10:46 +01:00
Alex Ellis (VMware)
8133414183 Read secrets from variable path
This change enables secrets to be read from any mount on disk
rather than hard-coding a certain location which suits Swarm or
K8s. The default value if not specified will look in the Swarm
location of /run/secrets/

README.md (docs) updated and set to off by default.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-05-23 11:42:42 +01:00
Alex Ellis (VMware)
a38931ce69 Enable basic auth on gateway
Fixes https://github.com/openfaas/faas/issues/687 allowing the
gateway to handle the responsibility of basic auth for when it is
in use.

To enable set basic_auth env-var to true and then mount two
secrets or plaintext files under /var/secrets/

basic_auth_user, basic_auth_password

Tested with faas-cli list/deploy and with Safari browser.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-05-23 11:42:42 +01:00
Alex Ellis (VMware)
4123270235 Add health and info endpoints
Fixes issue 689 by enabling /healthz and /system/info, see
swagger for more details.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-05-20 19:11:21 +01:00
Alex Ellis (VMware)
daa79aef75 Deprecate routeless proxy test
Routeless proxy allowed no HTTP path to be given when a Header
X-Function: name was given. This has been deprecated - I am
unaware of any usage of the feature.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-04-03 17:55:44 +01:00
Alex Ellis (VMware)
9a1b119c9f Remove Prometheus tracking for forwarded requests
Forwarded requests were being logged in the function metrics and
I saw this when doing some testing on auto-scaling with K8s.

This change removes the call to the Prometheus notifier for any
calls which are forwarded to the provider and retains them for the
functions.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-26 13:12:29 +01:00
John McCabe
fac3345668 Use http package consts for http methods
This commit replaces occurences of http method strings with the
corresponding consts from the http package.

*Note* UPDATE is not strictly speaking a valid method and as such isn't
part of the http package (should be a PUT or PATCH?)

Signed-off-by: John McCabe <john@johnmccabe.net>
2018-03-23 16:37:33 +00:00
Alex Ellis
0c7e59fe8a Add direct_functions mode to gateway for tuning
Adds a pair of configuration options for performance tuning. The
gateway can now invoke functions directly and can bypass the
provider. See updated table in README.md for configuration values.

BaseURLResolver is added with unit tests that decouples resolving
upstream URL from the reverse proxy client code.

- SingleHostBaseURLResolver resolves a single upstream host
- FunctionAsHostBaseURLResolver resolves host based upon conventions
within the URL of the request to a function for direct access

Tested with Kubernetes (faas-netes) and faas-swarm through UI, CLI
calling system endpoints and functions directly.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-23 16:35:37 +00:00
Alex Ellis (VMware)
c716c54868 Break out logging / metrics for functions in forwarding_proxy
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-20 09:51:42 +00:00
Alex Ellis
6efaee5b4f Add upstream_timeout as env-var
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2018-03-05 12:49:25 +00:00
Alex Ellis
7120e4c5f4 Apply comments and naming conventions to HTTP proxy
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2018-03-03 17:36:33 +00:00
Alex Ellis
26e0de3497 Remove Golang reverseproxy and use http Client
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2018-03-03 17:36:33 +00:00
Alex Ellis (VMware)
b67d0526ce Expose function endpoint from underlying provider
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-01 08:34:32 +00:00
Alex Ellis
f954bf0733 Merge master into breakout_swarm
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2018-02-01 09:29:54 +00:00
Alex Ellis
b1e92f6b93 Add call-id via middleware
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-12-13 06:18:44 -08:00
Alex Ellis
3d210f1ff2 Extract handler_set.go
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-12-05 06:50:08 -06:00
Alex Ellis
23a7187435 Refactoring: variable names, adding tests and http constants
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-12-05 06:50:08 -06:00
Alex Ellis
78a4580ead Allow CORS to GitHub raw
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-29 09:48:58 +01:00
Alex Ellis
8363532751 Set content-type for mixed-in Prometheus results
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-29 15:21:23 +00:00
John McCabe
89878f0c8a Migrate from alexellis org to openfaas
Note, not all `alexellis/github` references should be changed, there are
a number of repos which are not part of the openfaas org, this commit
excludes those.

Signed-off-by: John McCabe <john@johnmccabe.net>
2017-10-04 09:18:06 +01:00
John McCabe
40e1fac1c2 Implement Swarm update handler using PUT
This commit implements an update handler for Docker Swarm, it queries the
current spec, updates values in-situ before calling ServiceUpdate.

The UpdateConfig FailureAction is set to rollback, so in the event of
supplying values to the update that would result in the service failing
then the update will be rolled back.

The UpdateConfig Parallelism param is set to an explicit value of 1 which
will result in functions being updated 1 by 1 rather than all at once.

It also moves the restartDelay declaration out of the create and update
handlers and into the main server function alongside maxRestarts.

And finally this commit uses the PUT HTTP verb for updates rather than
the non-HTTP UPDATE verb which was being used initially (also adding it
to the Swagger definition).

Signed-off-by: John McCabe <john@johnmccabe.net>
2017-09-27 09:58:03 +01:00
Alex Ellis
2229e922d7 Add update endpoint/route
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-23 20:42:13 +01:00
Alex Ellis
d2b15241c6 fix x-header
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-19 22:14:04 +01:00
Alex Ellis
ec22a301fe Refactor out handler file from server.go
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-13 10:28:40 -07:00
Alex Ellis
5339fdcdbe Query Prometheus API for stats.
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-07 22:42:27 +01:00
Alex
fa069e412c Remove Docker client from NATS
Signed-off-by: Alex <alexellis2@gmail.com>
2017-08-29 19:40:08 +01:00
Alex Ellis
bd146f526c Sync async_nats work with master
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-08-29 19:40:08 +01:00
Alex Ellis
c5815d36ab add_missing_mit_header_27_aug
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-08-27 22:37:19 +01:00
Alex Ellis
c163b7d2a8 Add gateway_service_count metric for external provider
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-08-25 08:14:05 +01:00
Alex
3ac73340c3 Allow restarts of up to 5 times with 5 sec delays
Signed-off-by: Alex <alexellis2@gmail.com>
2017-08-16 21:34:05 +01:00
Alex Ellis
f165ce2ca7 External replica proxy 2017-08-08 09:14:46 +01:00
Alex Ellis
33381a783a External alert-handler support. 2017-08-08 09:14:46 +01:00
Alex
1e4b5f907a Wrap scaling / alert handling in interface/adapter pattern. 2017-08-08 09:14:46 +01:00
Alex
fa210a0dd3 Move HttpAdapter to own file 2017-08-08 09:14:46 +01:00
Alex
9df92c7f1b Start logging metrics 2017-08-08 09:14:46 +01:00
Alex
35a15cff01 Support external URL for FaaS functions 2017-08-08 09:14:46 +01:00
leigh schrandt
cc3308a555 Relocate config_test to tests package and
Export struct members of GatewayConfig{}
2017-07-18 08:46:46 +01:00
leigh schrandt
457d0be78b Add GatewayConfig
Add env configurable readTimeout / writeTimeout
Add env-timeout test
Modify appropriate Dockerfiles

Signed-off-by: leigh schrandt <leigh@null.net>
2017-07-18 08:46:46 +01:00
Alex Ellis
968002c15f Extract magic variables for server 2017-05-08 13:42:14 +01:00
Alex Ellis
0b2d3ea6c0 Move static files to ui folder 2017-05-08 13:42:14 +01:00
Alex Ellis
78af82021f Vendoring with Glide and delete function handler 2017-04-27 09:29:14 +01:00