139 Commits

Author SHA1 Message Date
Thomas Schmidt
67598e58c5 Update projects to use Go 1.13
Fixes #1442

Signed-off-by: Thomas Schmidt <thomaschmidt@gmail.com>
2020-02-22 19:01:49 +00:00
Vivek Singh
9fd8a59b89 Update logs to reudce verbosity and consistency
Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2020-01-24 12:39:16 +00:00
Alex Ellis (OpenFaaS Ltd)
4873e08d73 Add test to show TransferEncoding being passed to function
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-01-06 21:41:05 +00:00
Alex Ellis (OpenFaaS Ltd)
6a30ce1e36 Add transfer-encoding to watchdog env-vars if present
The Content-Type header must be ignored when the Transfer
Encoding is set to "chunked" because the length is unknown

Go sets this to -1 and we pass that onto the user:
https://golang.org/src/net/http/transfer.go

The value of Content_Length is currently set to -1 in this
scenario, however it caused some confusion for at least one
user in issue: #1422.

The Http_Transfer_Encoding value was tested by running the
watchdog on Linux with "env" as the fprocess and an extra
header to "curl"

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2020-01-06 21:41:05 +00:00
Alex Ellis (OpenFaaS Ltd)
80b6976c10 Update Golang versions to 1.12
Tested with local Docker build for each component.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-12-27 17:53:19 +00:00
Alex Ellis (OpenFaaS Ltd)
4d4ecc6bbf Add -run-healthcheck flag
This flag is useful for some users that prefer a scratch image
that cannot execute a bash healthcheck. Instead they can execute
the watchdog itself such as:

"watchdog -run-healthcheck"

It will return a non-zero exit code for when the lock file is not
found.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-11-28 20:26:28 +00:00
Alex Ellis (OpenFaaS Ltd)
64f5508c36 Wording on health-check
Via feedback from @jonatasbaldin, thank you

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-09-03 08:20:19 +01:00
Jonatas Baldin
f84b342ff1 Change health checks to healthchecks in watchdog README
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
2019-09-03 08:19:11 +01:00
Jonatas Baldin
4f3f008ba3 Fix some typos in the watchdog/README.md file
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
2019-09-03 08:19:11 +01:00
Alex Ellis (OpenFaaS Ltd)
cdfa01208d Bump versions
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-08-22 15:48:23 +01:00
haozibi
e8b3818300 chore: add log for easy debug
Signed-off-by: haozibi <haozibi@foxmail.com>
2019-07-11 10:25:17 +01:00
Alex Ellis
481482279c Consolidate listen / timeout messages
This brings of-watchdog and the classic watchdog into sync.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-07-11 10:12:48 +01:00
Sargun Dhillon
b019f6ca54 Add Concurrency Limiter
This enables limiting concurrency. It is a naive approach which
will reject requests as soon as they exceed the maximum number
of in-flight requests.

It is a port of the following PR from the new watchdog code:
https://github.com/openfaas-incubator/of-watchdog/pull/54

Signed-off-by: Sargun Dhillon <sargun@sargun.me>
Signed-off-by: Lucas Roesler <roesler.lucas@gmail.com>
2019-06-16 15:23:20 +01:00
Alex Ellis
a03196342d Push multi-arch image for watchdog
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-05-26 19:51:06 +01:00
Richard Gee
9eafa0bfd7 Create one watchdog image per arch
Signed-off-by: Richard Gee <richard@technologee.co.uk>
2019-04-25 14:01:32 +01:00
Richard Gee
5e2112af50 Bundle watchdog binaries into an image
Signed-off-by: Richard Gee <richard@technologee.co.uk>
2019-04-25 14:01:32 +01:00
Matias Pan
0384832299 Add unit tests for new env variable
Signed-off-by: Matias Pan <matias.pan26@gmail.com>
2019-04-04 21:28:17 +01:00
Matias Pan
9477970924 Add Http_Content_Length to env variables
Http_ContentLengh will be deprecated in the future.

Signed-off-by: Matias Pan <matias.pan26@gmail.com>
2019-04-04 21:28:17 +01:00
Alex Ellis
fa93655d90 Update test for metrics server
Updates metrics server test so that it checks for the status
code and that bytes are returned.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-04-04 09:05:17 +01:00
Alex Ellis
634ec22c8d Add RED metrics
- this PR adds metrics via Prometheus for instrumentation and
to move towards using HPAv2 / custom metrics in Kubernetes.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2019-04-04 09:05:17 +01:00
Ron Rivera
33800a20d8 Update watchdog to 0.9.14 for sample functions
We need to update the watchdog version for sample functions to 0.9.14
including all references in markdown files.

Signed-off-by: Ron Rivera <roncrivera@gmail.com>
2019-01-13 08:40:07 +00:00
Mike Chiu
1261aadebe Fix fwatchdog timer memory leak issue
Use timer.AfterFunc to make sure goroutine could be gc.

Signed-off-by: Mike Chiu <mike.chiu@pentium.network>
2019-01-02 22:46:03 +00:00
Radoslav Dimitrov
204c0d7f9a Bump the watchdog version to 0.9.6
Signed-off-by: Radoslav Dimitrov <rdimitrow@gmail.com>
2018-10-19 08:45:05 +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
Martin Dekov (VMware)
4d73e21906 Bump watchdog to 0.9.4
Bumping the watchdog to 0.9.4 in
mentioned places

Signed-off-by: Martin Dekov (VMware) <mdekov@vmware.com>
2018-09-19 21:04:53 +01:00
Alex Ellis (VMware)
e67811c91c Alter graceful shutdown sequence
- the shutdown sequence meant that the kubelet was still passing
work to the watchdog after the HTTP socket was closed. This change
means that the kubelet has a chance to run its check before we
finally stop accepting new connections. It will require some
basic co-ordination between the kubelet's checking period and the
"write_timeout" value in the container.

Tested with Kubernetes on GKE - before the change some Pods were
giving a connection refused error due to them being not detected
as unhealthy. Now I receive 0% error rate even with 20 qps.

Issue was shown by scaling to 20 replicas, starting a test with
hey and then scaling to 1 replica while tailing the logs from the
gateway. Before I saw some 502, now I see just 200s.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-09-17 11:48:16 +01:00
Radoslav Dimitrov
c821585b39 Sample-functions: Get watchdog using curl instead of ADD - Docs
Convert all sample-functions to use curl to get the watchdog as
it can be cached by Docker. Issue #841

Signed-off-by: Radoslav Dimitrov <rdimitrow@gmail.com>
2018-09-06 15:03:10 +01:00
Edward Wilde
e9f5be107b Adds support for additional PATCH HTTP verb
Full list of supported verbs is now supported: "GET", "POST", "PUT",
"PATCH", "DELETE"

Relates to: #openfaas/faas/issues/815

Signed-off-by: Edward Wilde <ewilde@gmail.com>
2018-08-22 20:10:03 +01:00
Alex Ellis (VMware)
9a879c96c3 Add note on health-checks for Kubernetes and Swarm
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-21 14:57:28 +01:00
Alex Ellis (VMware)
03015e48bd Add test for Http_path for watchdog.
This test takes inspiration from the PR from @telackey with changes
to make it more maintainable. Since the test does not require
changes to the code, I wanted to add it before merging changes.

Ref: https://github.com/openfaas/faas/pull/789

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-13 17:57:44 +01:00
Alex Ellis (VMware)
a4c867fd8f Adds HTTP Host entry
Fixes: https://github.com/openfaas-incubator/of-watchdog/pull/24

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-13 17:42:49 +01:00
Ivana Yovcheva (VMware)
099362b51d Move watchdog from functions/ to openfaas/ ns
This moves watchdog to a better name for images and also gives free
image-scanning and gives more confidence  to users  that components
ship regularly and makes any vulnerabilities  in  components  clear

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
2018-07-10 21:09:30 +01:00
Alex Ellis (VMware)
95c738c47e Remove typo in heading: afterburn
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-09 21:45:26 +01:00
Alex Ellis (VMware)
0149bf3aca Remove AfterBurn reference
Afterburn is deprecated in favour of of-watchdog. Removing link
to prevent confusion.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-07-09 21:43:59 +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
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
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
Ivana Yovcheva (VMware)
975cf4be7c Update watchdog version to 0.8.0
This updates watchdog version to latest 0.8.0 in the functions
samples and documentation

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
2018-05-11 14:14:59 +01:00
Alex Ellis (VMware)
cb2e3c3251 Add new source file to Dockerfile
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-04-14 17:48:28 -07:00
Alex Ellis (VMware)
08a080dcb2 Print version flag on every run
Moves handler code into separate file but retains same
package.

Changes watchdog to print version on start-up so that we can
grab this from logs. Version flag is also present for getting
additional information if needed from a user's published
container without running their function.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-04-14 17:48:28 -07:00
Vivek Singh
c258637d6d Added -version flag to watchdog
This changes introduces a new flag -version to watchdog which will
display version and SHA of last git commit.

Version and SHA are injected at build time and passed as a
build-args for Dockerfile.

Fixes: #632

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-04-14 17:19:53 -07:00
Ivana Yovcheva (VMware)
f936dcd757 Update watchdog version to 0.7.9 in function templates and docs
This updates fwatchdog to latest version (0.7.9) in all templates
in sample-functions and faas version in the documentation

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
2018-04-12 22:36:26 -07:00
Alex Ellis (VMware)
bbbb4b536a Bump watchdog to 1.9.4
Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-04-03 17:55:44 +01:00
Alex Ellis (VMware)
de2c74fcdb Add feature for graceful shutdown of HTTP server
If the watchdog is sent SIGTERM from an external process then it
should stop accepting new connections and attempt to finish the
work in progress. This change makes use of the new ability in Go
1.9 and onwards to cancel a HTTP server gracefully.

The write_timeout duration is used as a grace period to allow all
in-flight requests to complete. The pattern is taken directly from
the offical example in the Golang documentation. [1]

Further tuning and testing may be needed for Windows containers which
have a different set of signals for closing work. This change aims
to cover the majority use-case for Linux containers.

The HTTP health-check is also invalidated by creating an and
expression with the existing lock file.

Tested with Kubernetes by deploying a custom watchdog and the
fprocess of `env`. Log message was observed when scaling down and
connections stopped being accepted on terminating replica.

Also corrects some typos from previous PR.

[1] https://golang.org/pkg/net/http/#Server.Shutdown

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-24 16:38:46 +00:00
John McCabe
f9d081accb Remove invalid UPDATE HTTP Method from watchdog
The UPDATE HTTP Method isn't valid and not currently in use by the
watchdog so removing it.

Signed-off-by: John McCabe <john@johnmccabe.net>
2018-03-23 16:37:33 +00:00
John McCabe
fac3345668 Use http package consts for http methods
This commit replaces occurences of http method strings with the
corresponding consts from the http package.

*Note* UPDATE is not strictly speaking a valid method and as such isn't
part of the http package (should be a PUT or PATCH?)

Signed-off-by: John McCabe <john@johnmccabe.net>
2018-03-23 16:37:33 +00:00
Alex Ellis (VMware)
a841e3d7f3 Fix bug reading default value for combine_output
The default should be set to true so we maintain backwards.
compatibility.
readconfig.go was altered due to bug reading default value. This was
tested by adding unit tests to readconfig_test.go for positive and
negative scenarios.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-22 11:23:49 +00:00
Vivek Singh
c484eeecdb Add /_/health endpoint to watchdog
Introduce new endpoint `/_/health` to watchdog for health status of
functions  which check for `/tmp/.lock` file

Fixes first part of #547 issue.

Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
2018-03-20 08:52:22 +00:00
Alex Ellis (VMware)
30cf8de89b Update combine_output test
Integration test for combine_output should use stat instead of
man as man is not installed in the CI system.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-17 21:12:44 +00:00
Alex Ellis (VMware)
3031d0e1c2 Feature: combine_output to control stdout/stderr
This enables an often-requested feature to separate stderr
from stdout within function responses. New flag combine_output is on
by default to match existing behaviour. When combine_output is set
to false it redirects stderr to the container logs rather than
combining it into the function response.

Tested with unit tests for default behaviour and new behaviour.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-17 20:59:47 +00:00