504 Commits

Author SHA1 Message Date
Alex Ellis (OpenFaaS Ltd)
4bd07e24d9 Update Go version to 1.23
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-12-09 09:41:00 +00:00
Alex Ellis (OpenFaaS Ltd)
349c58e084 EULA: Expiry of licence key invokes termination
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-11-29 16:12:38 +00:00
Alex Ellis (OpenFaaS Ltd)
2fb748e03d Allow CE gateway to proxy telemetry handler from OEM/Pro backend
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2024-11-29 14:51:19 +00:00
Alex Ellis (OpenFaaS Ltd)
ab2c34bb34 Update vendor
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2024-11-18 21:45:59 +00:00
Alex Ellis (OpenFaaS Ltd)
49053feac7 Clarify EULA applies to this project since 2019
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2024-11-18 21:20:38 +00:00
Han Verstraete (OpenFaaS Ltd)
4e80b96d19 Set default user agent in proxy client
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
2024-08-07 10:35:58 +01:00
Alex Ellis (OpenFaaS Ltd)
1379805240 Switch to Default HTTP client for Prometheus queries
A new / empty client isn't necessary for these queries.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-08-07 09:41:20 +01:00
Alex Ellis (OpenFaaS Ltd)
546bfee9dc Add User-Agent to Prometheus Queries
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-08-07 09:39:31 +01:00
Alex Ellis (OpenFaaS Ltd)
637b0b045f Updates to GitHub Actions versions
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-07-16 09:44:16 +01:00
Alex Ellis (OpenFaaS Ltd)
32b4117aea Dockerfile linting and alpine linux update
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-07-16 09:42:21 +01:00
Alex Ellis (OpenFaaS Ltd)
3826262779 Update transitive dependencies
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-06-17 11:54:29 +01:00
Alex Ellis (OpenFaaS Ltd)
3d2808354d Update go.mod, Alpine to 3.20.0 and to Go 1.22
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-05-31 13:55:12 +01:00
Alex Ellis (OpenFaaS Ltd)
5f0fa69c2c Fix two typos
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-04-28 13:38:58 +01:00
Alex Ellis (OpenFaaS Ltd)
b22cb639fe Update error handling for empty metrics responses in exporter
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-04-02 12:20:36 +01:00
Alex Ellis (OpenFaaS Ltd)
667577f3ce Remember to close HTTP body from response
Flagged via community in:

https://github.com/openfaas/faas/pull/1836

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-04-02 12:15:16 +01:00
Alex Ellis (OpenFaaS Ltd)
5c13f1f01c Fixes for request body passing into text streaming proxy
In the previous version, whilst responses were streamed
correctly, the request body was not being received by
the function. This has been tested, along with adding
a forced timeout according to upstream_timeout, which
was a miss in the original commit.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-01-11 17:41:54 +00:00
Alex Ellis (OpenFaaS Ltd)
4679f27804 Support streaming responses from functions
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2024-01-11 10:56:40 +00:00
Alex Ellis (OpenFaaS Ltd)
9ba4a73d5d Rename Makefile targets
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-10-23 11:29:55 +01:00
guoguangwu
4f4e3d288a chore: remove refs to deprecated io/ioutil
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
2023-09-14 10:09:23 +01:00
Alex Ellis (OpenFaaS Ltd)
d0eec5fbbf Update Call ID Middleware
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2023-09-13 21:53:52 +01:00
Alex Ellis (OpenFaaS Ltd)
6a9ece3cc1 Update module to Go 1.20
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-08-22 18:38:00 +01:00
Alex Ellis (OpenFaaS Ltd)
2a88b5d2f7 Remove ioutil usage
This has been deprecated in Go for some time, in favour of the
io package.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-08-22 18:29:28 +01:00
Alex Ellis (OpenFaaS Ltd)
68ec0f59d6 Migrate to latest faas-provider version
Adds CRUD for namespaces and moves namespace for delete/
scale to the body from the query string.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-07-07 09:52:36 +01:00
Lucas Roesler
373a79256f Remove generated models
Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2023-06-28 08:33:03 +01:00
Lucas Roesler
06ade37420 feat: refactor api spec to use OpenAPI and add missing spec
Convert the existing swagger2.0 file to a moden OpenAPI file.
Add missing endpoitns and model definitions.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2023-06-28 08:33:03 +01:00
Alex Ellis (OpenFaaS Ltd)
910b8dae1b Update go.mod to 1.19 spec
This is not related to the Go version being used, but the min
version a developer can use to contribute.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-06-07 16:07:11 +01:00
Alex Ellis (OpenFaaS Ltd)
00613347f8 Implement scaling ranges
Scaling ranges keep the OpenFaaS CE gateway's requests to
within the intended bounds already implemented in other
components.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-06-07 16:05:37 +01:00
Alex Ellis (OpenFaaS Ltd)
a128df471f Function-based metrics for CE
OpenFaaS CE exposes metrics about function invocations and
about the gateway itself. OpenFaaS Pro has a richer set of
metrics including HTTP RED.

See also: https://docs.openfaas.com/architecture/metrics/

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2023-01-28 09:10:48 +00:00
Alex Ellis (OpenFaaS Ltd)
c26ec5221e Updates for NATS Streaming support
NATS Streaming is deprecated and will be removed from OpenFaaS
CE in a future release for security reasons.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2023-01-17 21:55:48 +00:00
Alex Ellis (OpenFaaS Ltd)
8e1c34e222 Set default max scale to 5 replicas and a 10% increment
Sets a new default maximum scale limit of 5 replicas out of
the box for CE users, CE meaning "Community" rather than
"Commercial".

The increment factor of 10 vs 25 should not make a difference
to genuine community and hobbyist users.

Tested and verified with unit tests and hey with a CE cluster
where the maximum limit was reached over several minutes,
finally going back to 1 replica.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2023-01-17 21:16:32 +00:00
Alex Ellis (OpenFaaS Ltd)
fbc0ebdf4a Add comment to middleware
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-01-11 13:10:46 +00:00
Alex Ellis (OpenFaaS Ltd)
4f9c61b5d2 Deprecate external auth plugins
There is no need for OpenFaaS CE to have external auth plugins
since this added extra overhead and was never used.

OpenFaaS Pro retains the option so it can use the OIDC
auth plugin.

It's still possible, as it ever was to put a proxy in front
of any HTTP server like the gateway.

Tested with a local KinD cluster, auth still worked for the
API and UI.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-01-11 12:22:12 +00:00
Alex Ellis (OpenFaaS Ltd)
a7d486eee6 Make OpenFaaS CE use the provider for load-balancing
This change removes the direct functions option which was
used originally for Docker Swarm. The Community Edition will
rely on the faas provider - faas-netes / faasd for load-balancing
of requests.

Direct Functions is required in order to delegate load-balancing
to Istio, Linkerd or some other kind of service mesh.

Tested by deploying a modified gateway image to a KinD cluster,
deploying the env function, and scaling to two replicas. This
balanced the load between the two pods by printing out the names
and then I ran a test with hey which returned 200s for all the
requests.

The prober which was part of the Istio support is no longer
required in the CE gateway so is removed for simplicity.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2023-01-11 12:12:26 +00:00
流雨声
b1ef4b49b7 fix: use io.ReadAll replace ioutil.ReadAll
ioutil.ReadAll will delete in future

Signed-off-by: 流雨声 <212724256@qq.com>
2022-12-14 17:18:08 +00:00
Alex Ellis (OpenFaaS Ltd)
f3599f4699 Apply gofmt
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-12-14 11:40:43 +00:00
Alex Ellis (OpenFaaS Ltd)
e1c62f4875 Update Go and alpine versions
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-12-14 11:30:41 +00:00
Alex Ellis (OpenFaaS Ltd)
004bbddadb Update queue code for legacy NATS Streaming
NATS Streaming is deprecated and will have no support from
early 2023 by Synadia. Upgrade to OpenFaaS Pro as soon as
possible.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-12-14 11:24:45 +00:00
Lucas Roesler
c07bebbbc9 fix: return provider response during fnc listing errors
Return the original upstream response body when the the list request
returns an error. In general, the provider is returning useful and
actionable error messages for the user, the previous code hid this in
the logs and this is easy for user to overlook.

Additionally, remove an early return from error case after fetching
metrics. This looked like a bug and could result in empty api responses
if there was a prometheus error.

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2022-10-24 18:23:49 +01:00
Alex Ellis (OpenFaaS Ltd)
1a00a55c77 Use write interceptor from faas-provider
We now have two write interceptors, with one moved into
faas-provider. This commit makes the gateway use the new
external package and deletes its own.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-09-29 20:36:40 +01:00
Alex Ellis (OpenFaaS Ltd)
bc2eeff467 Improve errors when backend doesn't return JSON
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-09-21 09:09:48 +01:00
Alex Ellis (OpenFaaS Ltd)
887c804254 Improve error message when unable to list functions
Related to: #1022

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-09-21 08:53:04 +01:00
Alex Ellis (OpenFaaS Ltd)
8e711b3a0c Use Desired Replicas when scaling from zero
During some exploratory testing, I ran into an issue where
the gateway would attempt to scale a deployment from zero
replicas to min, despite there already being min replicas.

Why?

The scaling logic was looking for Available replicas when
it should have looked for Desired replicas. So when a
deployment had zero ready replicas due to readiness checks
failing, the gateway was attempting to scale from zero
to min.

This logic has been corrected and separated from the
a holding pattern where the gateway waits for a ready
replica.

Tested with KinD and an edited function which had a
readiness probe, which was failing and no ready
replicas. As desired, the gateway did not scale to min.

However, when setting desired replicas to zero, the
gateway did scale up as expected.

This change also modifies all print statements for
"seconds" and makes them use 4 decimal places instead of
the default which was a longer, more verbose string for
the logs.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-09-08 11:21:29 +01:00
Alex Ellis (OpenFaaS Ltd)
4604271076 Introduce welcome message and change default timeout
The welcome message shows the difference between
Pro and CE.

The timeout of 8 seconds was never going to be useful as
a default, so changing to 60 seconds.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-08-30 14:02:44 +01:00
Alex Ellis (OpenFaaS Ltd)
9fccc67b9c Remove OpenFaaS Pro metrics from OpenFaaS CE
* Removes service min and target metrics from the CE gateway

OpenFaaS Pro metrics are no longer required in OpenFaaS CE
since there is an OpenFaaS Pro gateway available.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-08-30 11:30:58 +01:00
Alex Ellis (OpenFaaS Ltd)
ce5ea178ec Upgrade x/sync, Prometheus client and faas-provider
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-08-24 18:12:23 +01:00
Alex Ellis (OpenFaaS Ltd)
b87b96ae45 Migrate to Go 1.18 and update dependencies
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-08-05 09:03:31 +01:00
Alex Ellis (OpenFaaS Ltd)
88eea5f62e 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>
2022-07-07 10:35:07 +01:00
Alex Ellis (OpenFaaS Ltd)
01841f605c Use sync package from unofficial Go library
Uses the sync package from the unofficial Go library instead
of simpler solution.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-06-29 09:43:58 +01:00
Alex Ellis (OpenFaaS Ltd)
6ed0ab71fb Move to single-flight for back-end queries
When querying for replicas during a scale up event, then the
gateway can overwhelm the provider with requests. This is
especially true under high concurrent load.

The changes in this PR limit the inflight requests.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-06-29 09:43:58 +01:00
Alex Ellis (OpenFaaS Ltd)
8f8a93d43f Add Makefile for testing gateway builds
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-06-29 09:43:58 +01:00