468 Commits

Author SHA1 Message Date
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
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
Ken Fukuyama
6d6a487711 Renamed externalwatcher to exporter
Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-08-24 09:01:41 +01:00
Ken Fukuyama
b73e14be92 Automatically select 'Download' for store functions
This minor fix selects the 'Download' radio button by default if the
function has a label with `com.openfaas.ui.ext`.
Closes #827

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-08-24 08:54:27 +01:00
Alex Ellis (VMware)
273c8a40e7 Make push.sh runnable
Added chmod +x

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-23 22:09:53 +01:00
Alex Ellis (VMware)
64e7de4288 Add armhf build steps
This will help with CI for ARMHF

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-23 21:44:03 +01:00
Alex Ellis (VMware)
8fe8120b36 Add missing files to ARM Dockerfile
Appears to have been missed during recent PRs from community.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-21 13:46:23 +00:00
Dmitri Rubinstein
c182a0af82 Started implementing Host header propagation for asynchronous invocations
Add Host field to the queue.Request struct and copy it from Host field
of the HTTP request when converting HTTP request to queue.Request in
MakeQueuedProxy function.

Signed-off-by: Dmitri Rubinstein <dmitri.rubinstein@googlemail.com>
2018-08-16 16:20:28 +01:00
Dmitri Rubinstein
fd0abe46dd Propagate Host header from gateway request to the function.
Host HTTP header was not propagated to the function because it is not
a part of http.Request.Header map.

Signed-off-by: Dmitri Rubinstein <dmitri.rubinstein@googlemail.com>
2018-08-16 16:20:28 +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
Edward Wilde
be907d220c Adds annotation attribute to CreateFunctionRequest
1. Add new annotation attributes which may be used
by the back-end for making scheduling or routing decisions.

2. Updated tests/README.md to give clearer instructions on creating and
tearing down the stack required to run the integration tests

3. Update ci.sh
 * Fail as soon as an error is encountered
 * Allow script to run locally in development environment, test if repos
are already cloned etc..
 * Deploy ./stack.yml used by existing integration tests

Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-07-20 19:51:17 +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)
a1c2c553a5 Add scale_from_zero flag
Added scale_from_zero to config, docs and wrote unit test for the
value.

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
Alex Ellis (VMware)
00c93f2ddf Add ReadOnlyRootFilesystem flag
Adds flag to denote root-filesystem should be made read-only.

Needed for downstream work and re-vendoring in faas-swarm/faas-
netes and openfaas-operator.

Closes #723

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-16 12:28:06 +01:00
Vivek Singh
07f3e8f624 Accept 202 as valid code for /system/scale-function/<function>
Updated gateway to accept 202 as valid response code for
/system/scale-function/<function> along with 200.

Fixes: #faas-netes/245

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-07-16 11:13:11 +01:00
Ken Fukuyama
db465b82a4 Added function url field and copy action to the UI
This change adds a function URL field to the UI and a 'copy to
clipboard' button next to it. If the browser does not support the copy
command, the copy icon will be hidden.

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
2018-07-16 11:12:38 +01:00
Alex Ellis (VMware)
cba817c499 Allow copyright verbiage
Allows: OpenFaaS Author(s)

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-09 22:06:57 +01:00
Alex Ellis (VMware)
5f6b6bf953 Update header
From Project to Author(s) for the catch-all. This file has my
copyright which is retained through the catch-all statement.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-09 21:25:03 +01:00
Edward Wilde
28c9ccd0aa Changes from pull request feedback
1. Use httptest.ResponseRecorder instead of custom implementation
StringResponseWriter.

2. Remove verbose log line in infohandler

Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-07-06 17:50:48 +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
Vivek Singh
e55c018c17 Update default secret mount path to /run/secrets/
This commit reverts the changes done in #738 to update the default
secret mount path to `/run/secrets/`

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-07-02 19:22:59 +01:00
Alex Ellis (VMware)
f4aab9197d Move from functions ns to openfaas for Hub
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-02 12:45:53 +01:00
Vivek Singh
ced39bcda7 Updated default secret mount path value
This changes updates the secret mount path default value to
/var/openfaas/secrets at serveral places. It has been changed
from /run/secrets/ to /var/openfaas/secrets after version 0.8.2

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-06-28 21:37:10 +03:00
Edward Wilde
e39dbd9584 Update nats-queue-worker package to 0.4.7
This package version supports running OpenFaas on hosts the contain `.`
in their hostname i.e. computer-a.acme.com

Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-06-21 23:00:01 +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
Lucas Roesler
6676d1b807 Trim tailing slash from service name before proxy
**What**
- When determining the service name of the function, remove any trailing
slashes, the slashes are not allowed in service names for either Swarm
or K8S, so this can only be a left over from the url path

**Why**
- This was preventing service resolution, and hence failed functions,
    when the function was called with a trailing slash

Fixes #714

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2018-06-16 16:05:09 -07:00
Sean Smith
2292aab829 Update to golang 1.9.7
Issue #660 has been open for a while to update to 1.9.6, this
performs the update to the latest in the 1.9 release (1.9.7)

Signed-off-by: Sean Smith <sean@wwsean08.com>
2018-06-16 08:37:11 -07: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)
0e0fde27dc Bump arm gateway go version
Moving minor version to 1.9.6

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-05-21 15:39:54 +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
Ivana Yovcheva (VMware)
7f6295c9cf Update alpine version to 3.7
This updates alpine version to 3.7 in sample-functions, gateway
and some markdown docas.

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
2018-05-11 14:14:59 +01:00
Rillian Grant
829262e493 Add message for when JavaScript is disabled
- Added padding to the "You need JavaScript page"
 - Added padding to the "You need JavaScript page" - Added info about the CLI tthe "You need JavaScript" page
 - Added a message for people who don't have JavaScript enabled

Signed-off-by: Rillian Grant <rillian.grant@hotmail.com>
2018-04-26 12:48:22 +01:00
ovation22
3c7e222ab2 Add blankslate to gateway UI
Adds a more informative screen when a function is not selected
or when there are no functions to select from.

Provides a button to deploy a new function
and more information on how to deploy using
faas-cli.

Signed-off-by: ovation22 <john@1north.com>
2018-04-25 17:55:33 +01:00
Alex Ellis (VMware)
811bbe6031 Apply gofmt
Previous PR from Simon or Ken broke build due to missing gofmt
in the PR. This PR applies it to resolve the build issue.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-04-11 20:46:20 -07:00