481 Commits

Author SHA1 Message Date
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
Alex Ellis (OpenFaaS Ltd)
cc2f38938e Add HTTP status code to histogram
The histogram for gateway_functions_seconds excluded the status
code that gives important information for setting up SLOs.

Fixes: #1725

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-06-01 10:14:18 +01:00
Alex Ellis (OpenFaaS Ltd)
e778a3a6de Move to Alpine 3.16 and add blog posts
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
2022-05-26 15:03:48 +01:00
Alex Ellis (OpenFaaS Ltd)
0d7ace76b6 Pin Alpine Linux patch version
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-05-06 17:43:02 +01:00
Alex Ellis (OpenFaaS Ltd)
b097c87b80 Update whitespace in Dockerfile
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-05-06 17:42:10 +01:00
Hilário Coelho
a530b9dd63 update prometheus client golang
update docker/distribution lib

Signed-off-by: Hilário Coelho <hilario.coelho@securityside.com>
2022-05-06 17:40:00 +01:00
Alex Ellis (OpenFaaS Ltd)
4602fa7c97 Fix typo in error message
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-03-25 10:16:03 +00:00
Alex Ellis (OpenFaaS Ltd)
b4293967d2 Upgrade to alpine:3.15 where possible
Upgrades OS for some base images, no expected issues.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-02-21 10:30:22 +00:00
Alex Ellis (OpenFaaS Ltd)
cdb6baddda Deference channel
The defer close statement was causing issues in CI

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-01-24 16:41:30 +00:00
Alex Ellis (OpenFaaS Ltd)
a07ef4c194 Use the latest license-check binary
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-01-24 16:09:12 +00:00
Alex Ellis (OpenFaaS Ltd)
feb649be86 Turn off query for usage for invocations
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-01-24 14:38:12 +00:00
Alex Ellis (OpenFaaS Ltd)
d85d5e7239 Export new metrics for OpenFaaS Pro scaling
* Add service target metric
* Add service min replicas metric
* Add scale type metric

These combined allow new auto-scaling modes and parameters
for OpenFaaS Pro customers.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2022-01-24 14:30:08 +00:00
Alex Ellis (OpenFaaS Ltd)
698713d21a Add open-containers label
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-10-22 10:16:06 +01:00
Alex Ellis (OpenFaaS Ltd)
a9a77f0eca Update to Alpine 3.14 for base images
3.13 has vulnerabilities

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-07-27 09:29:43 +01:00
Alex Ellis (OpenFaaS Ltd)
539f0a2c94 Remove queue folder from Docker build
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-07-26 17:31:09 +01:00
Alex Ellis (OpenFaaS Ltd)
58394bb1de Migrate away from queue type in faas project
The queue type now resides in the provider, so that there is
no risk of a circular reference.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-07-26 17:31:09 +01:00
Alex Ellis (OpenFaaS Ltd)
06a51373e2 Upgrade NATS client
For compatibility with newer NATS streaming version

https://github.com/openfaas/faas-netes/pull/819

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-07-26 17:31:09 +01:00
Alex Ellis (OpenFaaS Ltd)
a6dbb4cd02 Update faas-provider to include new field
Includes CreatedAt

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-03-11 21:06:33 +00:00
Alex Ellis (OpenFaaS Ltd)
f8576d5b5d Return error from upstream when calling list functions
This is currently being hidden and needs to be bubbled up
into the logs to show an issue with calling list functions
during a deletion in faasd.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-02-27 20:18:34 +00:00
Lucas Roesler
089cd332b8 Add explicit test for the logging notifier middleware
**What**
- Add unit test that verifies the behavior of the logging middleware in
  various reponse cases

Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2021-02-27 09:53:31 +00:00
Alex Ellis (OpenFaaS Ltd)
048a90a150 Reduce cache expiry
Reduce cache expiry to help support issues where a function
may be scaled down by a user, when it is still in use.

The 5s cache meant that all requests would fail until the
expiry. The 250ms setting is a 20x reduction.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-02-26 12:24:55 +00:00
Alex Ellis (OpenFaaS Ltd)
4bdb580ae7 Update provider to v0.17.0
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-02-26 08:53:26 +00:00
Alex Ellis (OpenFaaS Ltd)
d5b98a7078 Restore the X-Call-Id for synchronous calls
This appears to have been removed inadvertently whilst
adding scale from zero logic into the gateway.

Going forward, synchronous and asynchronous calls will have a
header populated.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-02-10 09:47:09 +00:00
Alex Ellis (OpenFaaS Ltd)
77be2f3403 Update to latest Alpine base image
Version alpine:3.13 is now available

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-01-31 09:23:55 +00:00