openfaas / of-watchdog

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

Parse integer, non-Duration timeout values #64

Closed alexellis closed 4 years ago

alexellis commented 5 years ago

Expected Behaviour

The classic watchdog supports parsing integer values i.e. 60 and interpreting that as 60s whenever a non-golang duration is given. of-watchdog should do that too, but @bmcstdio mentioned he didn't see that.

Current Behaviour

Only supporting Golang duration.

https://github.com/openfaas-incubator/of-watchdog/blob/master/config/config.go#L118-L127

Possible Solution

Update the parsing code to use the following:

https://github.com/openfaas/faas/blob/master/watchdog/readconfig.go#L31

Steps to Reproduce (for bugs)

  1. Create a new function using of-watchdog, i.e. node10-express
  2. Set the timeout value without s i.e. 5
  3. Observe this being interpreted as something like 5ms when the user may expect it to be 5s
  4. Update the code, and test again.

Context

https://github.com/openfaas-incubator/golang-http-template/pull/22#issuecomment-501776576

Waterdrips commented 4 years ago

/assign: me

Waterdrips commented 4 years ago

I'm seeing "5" or 5 being intepreted as 0s (of-watchdof 0.7.2) using node12 and python3-flask templates

Function is invoked and works with sleeps of 9s (highest i tested)

The fix im working on sets 5 as 5s :man_shrugging:

alexellis commented 4 years ago

Great stuff, you got the gist of it 👍