47 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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)
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
Alex Ellis (VMware)
85d1436707 Make use of config value for HTTP port override
As added by previous commit with unit tests.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-17 20:20:06 +00:00
Alex Ellis (VMware)
70e9a83e87 Allow override of HTTP port via env-var
HTTP port can now be overriden through use of "port" environmental
variable.

Prefer messaging "want" over "wanted" in error messages, this is more
idiomatic Golang.

Move away from Go ARMv6 (RPi Zero) and give ARMv7 as a minimum
version for release binaries.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-03-17 20:18:09 +00:00
Alex Ellis
87eed35806 Handle nil body for GET
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-06 09:30:01 +00:00
Alex Ellis
ebd24ad285 Pass body for GET - to support ElasticSearch-type queries
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-06 09:30:01 +00:00
Alex Ellis
c743586899 Re-enable the suppress-lock feature
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-11-04 11:00:12 +00:00
Alex Ellis
8314b3c0b5 Log fork/duration
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-31 11:34:29 +00:00
Alex Ellis
33e794abde Add Http_ContentLength for deterministic applications
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-29 17:49:20 +00:00
Burton Rheutan
ee88d42a14 Removed extra log statement on error
Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
2017-10-23 15:13:30 +01:00
Burton Rheutan
b9f59f5150 Fixes 251. Set debug_write to false by default. Added log output of byte count when debug is false. Updated tests to match new default
Signed-off-by: Burton Rheutan <rheutan7@gmail.com>
2017-10-23 15:13:30 +01:00
Alex Ellis
dde98eb582 Forward path and query string through proxy
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-11 18:57:00 +01:00
John McCabe
89878f0c8a Migrate from alexellis org to openfaas
Note, not all `alexellis/github` references should be changed, there are
a number of repos which are not part of the openfaas org, this commit
excludes those.

Signed-off-by: John McCabe <john@johnmccabe.net>
2017-10-04 09:18:06 +01:00
Alex Ellis
53edc286aa Fix gofmt
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-01 22:36:07 +01:00
Franklin Harding
6ebc314bdf Added os.TempDir() to replace using '/tmp/' to make the tempdir cross platform
Signed-off-by: Franklin Harding <franklinharding0.0@gmail.com>
2017-10-01 22:06:26 +02:00
Alex Ellis
b9be8293a8 Fix querystring passing
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-09-09 09:42:57 +01:00
Alex
6d436c576c watchdog - Write out headers with underscores
Signed-off-by: Alex <alexellis2@gmail.com>
2017-08-23 21:08:53 +01:00
Alex Ellis
ddc973c341 Watchdog - Write error / stack to caller. 2017-07-19 17:41:38 +01:00
Alex Ellis
4d05896798 Watchdog refurbishments
- Watchdog - allow new methods with and without body.
- Enforce hard-timeout via exec_timeout variable.
- Correct bug in timeouts for read/write of HTTP.
- Documentation for new verbs and hard timeout.

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-07-07 08:49:11 +01:00
Alex
cc0d351e69 Watchdog - enable forwarding of HTTP headers via CGI-like env vars. 2017-05-09 09:13:42 +01:00
Alex
fbb9646377 Add x-duration-seconds for all functions via watchdog 2017-05-03 18:49:30 +01:00
Alex
569ccbf323 Add license into code files for MIT 2017-04-27 23:21:50 +01:00
Alex Ellis
f958e99bdc Allow override of contentType response from watchdog. (#46) 2017-04-10 22:18:37 +01:00
Alex Ellis
469fc690da Fix issue in watchdog - not reading false config overrides. 2017-04-05 09:13:18 +01:00
Alex Ellis
93bdfba4b2 Rename marshal_request for watchdog, enable lock-file for healthcheck CMD. 2017-04-05 09:13:18 +01:00
Alex
c705cd8e33 Forward client HTTP headers through pipeline 2017-03-31 20:40:25 +01:00
Alex Ellis
04be17ce49 Add marshall_request to watchdog for passing header to functions 2017-03-31 20:40:25 +01:00
Alex Ellis
c2eb41ee4f Fix buffer dead-lock in Watchdog (#33)
* Go sync group to handle blocking on buffered-pipes
2017-03-28 19:05:33 +01:00
Alex
52266a6741 Match content-type of incoming request. Fix for Alexa. 2017-01-28 12:26:30 +00:00
Traun Leyden
dd67519cc4 Fix attempt for reported connection buildup
Regarding https://github.com/golang/go/issues/6785#issuecomment-275669472
2017-01-27 08:14:57 -08:00
Alex
d031e3154e Test makehandler 2017-01-24 20:54:24 +00:00
Alex
ed47c36d59 Add timeouts and unit test config. 2017-01-24 20:00:15 +00:00
Alex
b7d2845d6e Make timeouts configurable for watchdog process. Make debug into container optional. 2017-01-23 23:26:31 +00:00
Alex
502e13acab Combine stdout/stderr (experimental)
Don't panic on error, keep alive and return 500.
2017-01-23 18:32:35 +00:00
Alex Ellis
d181fed5fd Change samples to use get-stdin for brevity. 2016-12-30 19:40:49 +00:00
Alex Ellis
4573f14f65 Add changecolorintent 2016-12-30 19:24:25 +00:00
Alex Ellis
8fe7cb691d Initial 2016-12-22 13:08:32 +00:00