505 Commits

Author SHA1 Message Date
Alex Ellis (VMware)
a65df4795b Update swagger for missing secret definitions
- added secret definition and removed types used previously

Remove structs for secrets

- after discussion on PR the core contributors decided we just
want simple CRUD with the Secret type.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2019-01-04 16:51:01 +00:00
Andrew Cornies
b206cb829a Updated secret types based on PR feedback:
- SecretInfo type
- ListSecretsResponse
- Move Annotations to SecretInfo
- update swagger api docs

Signed-off-by: Andrew Cornies <acornies@gmail.com>
2019-01-04 16:51:01 +00:00
Andrew Cornies
b49dded3b3 Updates from PR comments:
- moved Vagrantfile to contrib dir
- gave secret request type more thought

Signed-off-by: Andrew Cornies <acornies@gmail.com>
2019-01-04 16:51:01 +00:00
Andrew Cornies
a9238f5631 Secrets iteration:
- added delete http verb to system/secrets
- added secrets request type
- added vagrant env provisioned by existing deploy_stack.sh

Signed-off-by: Andrew Cornies <acornies@gmail.com>
2019-01-04 16:51:01 +00:00
Andrew Cornies
d2ef8b9207 Initial support for secrets in gw:
- added SecretHandler type
- added discussed system/secret endpoint with appropriate http verbs

Signed-off-by: Andrew Cornies <acornies@gmail.com>
2019-01-04 16:51:01 +00:00
Lucas Roesler
c9befd78e7 Bump gorilla mux to 1.6.2
**What**
- Update the gopkg.toml

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2018-12-29 19:34:21 +00:00
Gede Wahyu
09736be293 When firing, newReplicas should be greater than currentReplicas
Signed-off-by: Gede Wahyu <tokekbesi@gmail.com>
2018-12-29 19:31:04 +00:00
Gede Wahyu
3bdb194e71 Round up value of newReplicas
Signed-off-by: Gede Wahyu <tokekbesi@gmail.com>
2018-12-29 19:31:04 +00:00
Gede Wahyu
191629151e Remove the differentiation between currentReplicas==1 and not
Signed-off-by: Gede Wahyu <tokekbesi@gmail.com>
2018-12-29 19:31:04 +00:00
Gede Wahyu
81db6514f7 Fix TestInitialScale expectation
Signed-off-by: Gede Wahyu <tokekbesi@gmail.com>
2018-12-29 19:31:04 +00:00
Gede Wahyu
058d1e481a Test scaled up from 1
Signed-off-by: Gede Wahyu <tokekbesi@gmail.com>
2018-12-29 19:31:04 +00:00
Lucas Roesler
334288b130 Undo early return in updateData callback
**What**
- Revert to original if-block structure to reduce the size of the diff

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2018-12-19 21:10:41 +00:00
Lucas Roesler
cb367096ae Refresh function image during ui update loop
**What**
- Update the function image value during the `refreshData`

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2018-12-19 21:10:41 +00:00
Burton Rheutan
a51d42c983 Download vendor cdn files for gateway
This change set downloads the CDN resources for the gateway
and bundles them with the other static resources for the UI.

This is needed for situations where a user does not have access
to the CDN either because of firewall rules or network policy.

The files and versions remain the same, only now loaded locally
with directory paths matching the CDN paths.

Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
2018-12-05 20:20:15 +00:00
Radoslav Dimitrov
350907aacd Update gateway to golang:1.10.4
Signed-off-by: Radoslav Dimitrov <rdimitrow@gmail.com>
2018-12-05 19:59:18 +00:00
Alex Ellis (VMware)
6ef5ef73cc Update arm64 build of gateway
- adds version folder - tested on Rock64

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-12-04 11:15:38 +00:00
Martin Dekov (VMware)
ade5f32513 Bump files to use alpine:3.8
Bump Dockerfiles and mentions of alpine 3.7 to be now
3.8

Signed-off-by: Martin Dekov (VMware) <mdekov@vmware.com>
2018-11-16 20:27:05 +00:00
Alex Ellis (VMware)
b4c12f824b Make use of cache in scaling
- this reinstates the cache to reduce the count of lookups to the
provider when checking if scaling is needed.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-11-07 13:49:56 +00:00
Alex Ellis (VMware)
117707df14 Enable backoff/retries on scaling up
- this change is needed for Docker Swarm which may give an error
when several concurrent requests come in to scale a deployment.

Tested on Docker Swarm before/after with the hey tool and figlet
scaled down to zero replicas.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-11-07 13:49:56 +00:00
Alex Ellis (VMware)
9cea08c728 Extract scaling from zero
- extracting this package means it can be used in other components
such as the asynchronous nats-queue-worker which may need to
invoke functions which are scaled down to zero replicas.

Ref: https://github.com/openfaas/nats-queue-worker/issues/32

Tested on Docker Swarm for scaling up, already scaled and not
found error.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-11-01 15:10:08 +00:00
Alex Ellis (VMware)
101b06243b Add documentation for scaling handler
- documents ScalingConfig and MakeScalingHandler

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-28 12:24:25 +00:00
Alex Ellis (VMware)
f5939c9a60 Update for scaling edge-case
- as reported on Slack and in issue #931 the gateway scaling code
was scaling to zero replicas as a result of the "proportional
scaling" added by @Templum's PR. This commit added a failing test
which was fixed by adding boundary checking - now if the scaling
amount is "0" we keep the current amount of replicas.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-25 11:47:47 +01:00
Richard Gee
7df548668f Add logging to scale from zero requests
Trivial change to add logging around scale from zero events in scaling.go.
Previously scale from zero events were not logged in the same way that normal
scaling events are.  This change adds log writes to show when a scale from zero
was requested and when a function successfully moved to > 0 replicas.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
2018-10-20 08:56:14 +01:00
qinpengfei
70a5e343c5 code formatter
Signed-off-by: qinpengfei <qinpengfei@jd.com>
2018-10-19 21:24:15 +01:00
Alex Ellis (VMware)
476b652c26 Update integration test
We now send Accepted not OK for creating functions.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-19 21:19:21 +01:00
Alex Ellis (VMware)
62525f6570 Don't follow redirects from functions
- Covers part of 919 by making the HTTP client used for proxying
stop following redirects. Tested with a stateless microservice,
but additional code changes may be requierd in the queue-worker,
the watchdogs and other areas.

Tested on Swarm with stateless microservice (Node.js) issuing
a redirect via Location header.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-19 21:19:21 +01:00
Alex Ellis
7db8ad1bda Update README files
- Removes use of "our" from CONTRIBUTING guide
- Updates/adds README.md files
- Commnents and typo fix in watchdog
- Adds good/bad examples of commit messages

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-03 14:07:41 +01:00
Alex Ellis
bd39b9267a Update comments
- updates comments and adds where missing
- updates locks so that unlock is done via defer instead of
at the end of the statement
- extracts timeout variable in two places
- remove makeClient() unused method from metrics package

No-harm changes tested via go build.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-10-03 13:16:28 +01:00
Richard Gee
e33061702a Change the http status code on unfound function error to 404
Signed-off-by: Richard Gee <richard@technologee.co.uk>
2018-09-23 12:39:13 +01:00
Richard Gee
df6f4c49f2 Add checking for existent function in GetReplicas
Within MakeScalingHandler() there is a call to GetReplicas() which was not returning an error when a non-200 http response was received from /system/function/.  The call would also return a populated struct, so the perception was that a function existed an had been scaled to zero.  This meant that the function would be added to the function cache and the code would continue into SetReplicas() where an attempt would be made to scale up a non-existent function.

This change amends GetReplicas() so that it will return an error if the gateway returns anything other than a 200 reponse code from the /system/function/ endpoint.  This causes MakeScalingHandler() to return earlier with an error indicating that the function could not be found.  The cache.Set call is also moved to after the error check so that the cache is only updated to include existent functions.

During investigations as to the cause of #876 tests were added to function_cache to check that Get() is behaving as intended when function exists and when not.  Tests are also added to plugin/external to test that GetReplicas() and SetReplicas() are following their intended modes of operation when 200 and non-200 responses are received from the gateway.

Signed-off-by: Richard Gee <richard@technologee.co.uk>
2018-09-23 12:39:13 +01:00
Alex Ellis (VMware)
3598da2e51 Enable basic auth for service query / scaling on provider
- this is a blocking issue for auth with Docker Swarm
fixes #879

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-19 20:52:14 +01:00
Alex Ellis (VMware)
c67c9f2b30 Fix issue with direct_functions and path behaviour
- The path clipping / transforming behaviour must be turned-off
when we are not using direct_functions as is used in
faas-nomad and faas-ecs. This will need a change in each provider
to strip paths, but fixes a 404 error these users will see if they
upgrade to 0.9.2 or newer. 0.9.3 will have a this fix meaning
the whole un-edited path is passed to the provider when
direct_functions is set to false.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-15 14:40:22 +01:00
Stefan Prodan
3e0ed5edd7 Add X-Forwarded-Host test when already present
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2018-09-10 09:57:03 +01:00
Stefan Prodan
3d44fa813a Set upstream X-Forwarded Host and For headers if not present
- remove http client host override fix #847
- X-Forwarded-For and X-Forwarded-Host are usually handled by the ingress
controller, if those headers are not set then the gateway will create them

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2018-09-10 09:57:03 +01:00
Vivek Singh
d926b2d886 Add basic auth support for /system/async-report
This commit adds basic authentication for `/system/async-report`
endpoint.

It also adds basic-auth secrets to `queue-worker` service which will be
used for gateway calls to `/system/async-report`.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-09-08 09:58:19 +01:00
Alex Ellis (VMware)
6937bc4d7f Move to auth package in faas-provider
The basic-auth middleware and credentials-loading code has been
moved into the faas-provider project. This has now been brought
back into the faas project via vendoring.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-06 16:14:53 +01:00
Alex Ellis (VMware)
ffd81afd02 Refactor #843
Code-review/refactoring for #843. Closes #843.

FaaSHandlers has had info and query handlers added to its list
of types for consistency.

Secrets added to queue-worker component ready for next PR.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-05 09:47:49 +01:00
Burton Rheutan
fa076fb2c4 Pass basic auth to all system calls
This changeset enables passing the basic auth credentials
to all /system/ calls to allow upstream providers to
perform authorization checks independent of the gateway.

This is essential for some providers, like Swarm, where
the system is accessible on the same network, and not
protected via the gateway

Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
2018-09-05 09:47:49 +01:00
Alex Ellis (VMware)
af0ccc9a45 Add Copyright headers where missing in handlers
- Added Copyright in handlers where missing
- Renamed Project to Author(s) where needed

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-03 13:26:58 +01:00
Alex Ellis (VMware)
9c2f6dd2a4 Fix bug introduced by URL transformer
This prevented Prometheus metrics from being gathered from the
URL.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-29 12:41:04 +01:00
Alex Ellis (VMware)
6055cafd4a Set Docker image NS to openfaas
This was altered to "alexellis" for building a testing image,
but shouldn't have been pushed. Reverting.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-29 12:41:04 +01:00
Alex Ellis (VMware)
e551d12b65 Add test coverage for FunctionPrefixTrimmingURLPathTransformer
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-29 12:41:04 +01:00
Alex Ellis (VMware)
4367fc4e35 Add test coverage for buildUpstreamRequest
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-29 12:41:04 +01:00
Alex Ellis (VMware)
2f98ca8802 Review changes for HTTP paths
This reviews the code and fixes up suggestions made by team for
the HTTP paths PR #789.

- Removed feature-flag (this is backwards-compatible, so I see
no value in adding the flag)
- There was a URL transform happening for calls proxied to the
back end, I changed this for the nil-transform - i.e. it does not
change anything in the URL
- Introduced variables to describe the regex indicies used in
the URL trimming.

Tested with Docker Swarm with a ruby-microservice, with
system calls and with function calls using the UI.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-29 12:41:04 +01:00
Thomas E Lackey
b1846b842c Add a non-capturing subgroup so that the function regex will match async functions as well.
Signed-off-by: Thomas E Lackey <telackey@bozemanpass.com>
2018-08-29 12:41:04 +01:00
Thomas E Lackey
8749e0d891 Only truncate '/function/...' paths.
Signed-off-by: Thomas E Lackey <telackey@bozemanpass.com>
2018-08-29 12:41:04 +01:00
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
ddc59f6403 Updated copyright
Added OpenFaaS Author(s) to show distributed copyright.

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-08-24 09:01:41 +01:00
Ken Fukuyama
9ceac9c67e Renamed ServiceReplicasCounter to ServiceReplicasGauge
To avoid future confusion, this fix renames ServiceReplicasCounter to
ServiceReplicasGauge.

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-08-24 09:01:41 +01:00