diff --git a/guide/troubleshooting.md b/guide/troubleshooting.md index 72d46f7b054810a512cb6018ccfaa0c3808c1710..c87cabc813d0a600916c6029a04075a3b5a68286 100644 --- a/guide/troubleshooting.md +++ b/guide/troubleshooting.md @@ -1,119 +1,138 @@ # Troubleshooting guide -## Watchdog +## Healthcheck -### Debug your function without deploying it +Most problems reported via GitHub or Slack stem from a configuration problem or issue with a function. Here is a checklist of things you can try before digging deeper: -Here's an example of how you can deploy a function without using an orchestrator - it's useful for testing: +Checklist: +* [ ] All core services are deployed: i.e. gateway +* [ ] Check functions are deployed and started +* [ ] Check request isn't timing out at the gateway or the function level -``` -$ docker run --name debug-alpine \ - -p 8081:8080 -ti functions/alpine:latest sh -# fprocess=date fwatchdog & -``` +## Docker Swarm -Now you can access the function with one of the supported HTTP methods such as GET/POST etc: +### List all functions ``` -$ curl -4 localhost:8081 +$ docker service ls ``` -### Edit your function without rebuilding it - -You can bind-mount code straight into your function and work with it locally, until you are ready to re-build. This is a common flow with containers, but should be used sparingly. - -Within the CLI directory for instance: - -Build the samples: +### Find a function's logs ``` -$ git clone https://github.com/alexellis/faas-cli && \ - cd faas-cli -$ faas-cli -action build -f ./samples.yml +$ docker swarm logs --tail 100 <function> ``` -Now work with the Python-hello sample, with the code mounted live: +### Find out if a function failed to start ``` -$ docker run -v `pwd`/sample/url-ping/:/root/function/ \ - --name debug-alpine -p 8081:8080 -ti alexellis/faas-url-ping sh -$ touch ./function/__init__.py -# fwatchdog +$ docker swarm ps --no-trunc=true <function> ``` -Now you can start editing the code in the sample/url-ping folder and it will reload live for every request. +### Stop and remove OpenFaaS ``` -$ curl localhost:8081 -d "https://www.google.com" -Handle this -> https://www.google.com -https://www.google.com => 200 +$ docker stack rm func ``` -Now you can edit handler.py and you'll see the change immediately: +If you have additional services / functions remove the remaining ones like this: ``` -$ echo "def handle(req):" > sample/url-ping/handler.py -$ echo ' print("Nothing to see here")' >> sample/url-ping/handler.py -$ curl localhost:8081 -d "https://www.google.com" -Nothing to see here +$ docker service ls -q|xargs docker service rm ``` -## Docker Swarm +*Use with caution* + +## Kubernetes ### List all functions ``` -$ docker service ls +$ kubectl get deploy ``` ### Find a function's logs ``` -$ docker swarm logs --tail 100 <function> +$ kubectl logs deploy/<function> ``` ### Find out if a function failed to start ``` -$ docker swarm ps --no-trunc=true <function> +$ kubectl describe deploy/<function> ``` -### Stop and remove OpenFaaS +### Remove the OpenFaaS deployment ``` -$ docker stack rm func +$ kubectl delete -f faas.yml,monitoring.yml,rbac.yml ``` -If you have additional services / functions remove the remaining ones like this: +## Timeouts + +Default timeouts are configured at the HTTP level for the gateway and watchdog. You can also enforce a hard-timeout for your function. + +For watchdog configuration see the [README](https://github.com/openfaas/faas/tree/master/watchdog). + +For the gateway set the following environmental variables: + +* read_timeout, write_timeout - the default for both is "8" - seconds. + +## Watchdog + +### Debug your function without deploying it + +Here's an example of how you can deploy a function without using an orchestrator - it's useful for testing: ``` -$ docker service ls -q|xargs docker service rm +$ docker run --name debug-alpine \ + -p 8081:8080 -ti functions/alpine:latest sh +# fprocess=date fwatchdog & ``` -*Use with caution* +Now you can access the function with one of the supported HTTP methods such as GET/POST etc: -## Kubernetes +``` +$ curl -4 localhost:8081 +``` -### List all functions +### Edit your function without rebuilding it + +You can bind-mount code straight into your function and work with it locally, until you are ready to re-build. This is a common flow with containers, but should be used sparingly. + +Within the CLI directory for instance: + +Build the samples: ``` -$ kubectl get deploy +$ git clone https://github.com/alexellis/faas-cli && \ + cd faas-cli +$ faas-cli -action build -f ./samples.yml ``` -### Find a function's logs +Now work with the Python-hello sample, with the code mounted live: ``` -$ kubectl logs deploy/<function> +$ docker run -v `pwd`/sample/url-ping/:/root/function/ \ + --name debug-alpine -p 8081:8080 -ti alexellis/faas-url-ping sh +$ touch ./function/__init__.py +# fwatchdog ``` -### Find out if a function failed to start +Now you can start editing the code in the sample/url-ping folder and it will reload live for every request. ``` -$ kubectl describe deploy/<function> +$ curl localhost:8081 -d "https://www.google.com" +Handle this -> https://www.google.com +https://www.google.com => 200 ``` -### Remove the OpenFaaS deployment +Now you can edit handler.py and you'll see the change immediately: ``` -$ kubectl delete -f faas.yml,monitoring.yml,rbac.yml +$ echo "def handle(req):" > sample/url-ping/handler.py +$ echo ' print("Nothing to see here")' >> sample/url-ping/handler.py +$ curl localhost:8081 -d "https://www.google.com" +Nothing to see here ```