468 Commits

Author SHA1 Message Date
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
Alex Ellis (OpenFaaS Ltd)
f98213a428 Remove git commit message from binary
This appears to have broken CI at least three times now and
prevented us from shipping a release binary for a tag.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-01-31 09:23:55 +00:00
Vivek Singh
82cd46ef2a Update version info endpoint
This commits updates version endpoint to use ProviderInfo and VersionInfo structs from
faas-provider.GatewayInfo now uses ProviderInfo and VersionInfo structs. GatewayInfo is
left within gateway. Consumer of this endpoint should use typed struct GatewayInfo to
parse response.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2021-01-30 14:53:57 +00:00
Alex Ellis (OpenFaaS Ltd)
7ce266adc0 Migrate to Go modules
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-01-21 19:04:22 +00:00
Alex Ellis (OpenFaaS Ltd)
2e2250afe8 Use a placeholder commit message for development
The faas-cli throws an error because it always expects a
commit_message for the gateway version, and if it's null - it
will crash. This only affects local development.

The code in faas-cli should be changed to use a struct instead
of casting to an interface.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2021-01-20 12:02:15 +00:00
Alex Ellis (OpenFaaS Ltd)
3f98c856e5 Remove Swarm references
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-12-16 10:01:21 +00:00
Alex Ellis (OpenFaaS Ltd)
8a5b3123e0 Remove Swarm resources from faas repo
This is part of the following activity:

https://github.com/openfaas/docs/pull/249

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-12-16 09:58:26 +00:00
Alistair Hey
ca3d53c0a5 Add publish step to github actions
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
2020-12-10 14:54:38 +00:00
Alistair Hey
e3b18e6324 Convert Basic-Auth to multi-arch
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
2020-12-10 14:54:38 +00:00
Alistair Hey
a5583074e0 Convert Gateway to Github Actions
Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
2020-12-10 14:54:38 +00:00
Alex Ellis (OpenFaaS Ltd)
4ced7cacd0 Update scaling polling interval
Polls every 100 ms instead of every 50ms for use with a new
faas-netes PR:

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

The call is much faster now, so this request should me made
at a lower frequency.

Also adds error handling for URL building in the external
service query code.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-12-10 14:00:31 +00:00
Alex Ellis (OpenFaaS Ltd)
9bbb25e3c7 Fix a bug that caused the services list to keep growing
This patch changes the code which looks up service and appends
them to the Exporter's list. It previously would create an
endless list and cause a memory leak.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-12-05 12:57:47 +00:00
Alistair Hey
7b6cc60bd9 Fix Invocation count wrong for multiple namespace
Fixes https://github.com/openfaas/faas/issues/1413
Fixes https://github.com/openfaas/faas-netes/issues/707

This fixes the Gateway UI not updating the
invocation count automatically without a page reload.

Tested by deploying on a local cluster and making sure invocations go up
with and without namespace suffix

Signed-off-by: Alistair Hey <alistair@heyal.co.uk>
2020-11-17 10:04:33 +00:00
Vivek Singh
c9c2b39601 Use namespace while filtering metric result
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2020-11-02 10:35:57 +00:00