openfaas / of-watchdog

Reverse proxy for STDIO and HTTP microservices
MIT License
259 stars 115 forks source link

Return 500 on non-zero exit status for Serializing and Streaming modes #14

Closed ericstoekl closed 5 years ago

ericstoekl commented 6 years ago

Signed-off-by: Eric Stoekl ems5311@gmail.com

Description

This PR is to bubble up non-zero exit code from the fprocess that is run by the of-watchdog as a 500 ISE response to the client which invokes the watchdog.

Motivation and Context

How Has This Been Tested?

Start the watchdog server with port=8081 mode=serializing fprocess="stat x" ./of-watchdog

Before the update, when you curl the endpoint it will return 200 OK despite the fprocess command failing.

$ curl localhost:8081 -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Date: Wed, 04 Apr 2018 14:48:20 GMT
Content-Length: 0

After update, it will return 500 if the fprocess command return non-zero:

$ curl localhost:8081 -i
HTTP/1.1 500 Internal Server Error
Content-Type: application/octet-stream
Date: Wed, 04 Apr 2018 15:11:24 GMT
Content-Length: 13

When running with a working fprocess (use pwd for the fprocess variable for example) I get a 200 response:

$ curl localhost:8081 -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Date: Wed, 04 Apr 2018 15:16:00 GMT
Content-Length: 64

/home/s/github/go/src/github.com/openfaas-incubator/of-watchdog

You will see the same results with the streaming (fork) mode.

Types of changes

Checklist:

alexellis commented 6 years ago

I think this will work and have a similar patch on my laptop from when I raised the issue. Let's re-evaluate which modes are needed in the of-watchdog and what else is different in this implementation.

alexellis commented 5 years ago

/close: inactive