Closed kwojcicki closed 2 years ago
Hi, thanks for your issue.
The status of the repo shows that this is not yet available:
https://github.com/openfaas-incubator/of-watchdog/blob/master/README.md#configuration
Alex
Wow sorry I am blind :laughing:
I think it's ok to track this.
I can change this to track the progress of implementing write_debug :)
Hey @alexellis I was taking a look at what would be needed to get write_debug working.
In the code I see https://github.com/openfaas-incubator/of-watchdog/blob/master/executor/http_runner.go#L72 from my understanding this doesn't work as the forked process never ends (until of course the pod gets killed) meaning we can never read from the standardInPipe as the output is getting buffered.
It seems some languages can allow output to be unbuffered https://stackoverflow.com/a/20564618. Or one could use a PTY https://github.com/creack/pty, this would add another dependency but I believe write_debug is super valuable and worth the additionally overhead :)
Maybe I am missing a cleaner way to implement this, but if not I would like to go ahead with using the creack/pty. Let me know what you think
I don't think that's the reason that the output cannot be printed. In order to print the output, we first have to buffer it in memory and that's something which wasn't done in the HTTP implementation.
https://github.com/openfaas-incubator/of-watchdog/blob/master/executor/http_runner.go#L111
write_debug
is supposed to print the output of the function response.
We can do that easily by checking the flag and printing the content here:
https://github.com/openfaas-incubator/of-watchdog/blob/master/executor/http_runner.go#L183
It turns out that we do buffer the response.
In the HTTP mode we do not use STDIO for function input or output.
See this diagram:
https://docs.openfaas.com/architecture/watchdog/#of-watchdog
@alexellis ah okay so if someone uses the http mode they themselves are responsible for packaging up the logs in the http response and then write_debug will print out the response in the logs. So the response from the function may look like {"body": {"logs":"lots of stuff from all my system.out.println or fmt.println", "actual-response": "..."}}
?
What is it you're trying to get to?
write_debug
is so that the response of the function is written to the container logs, is that what you are looking for?
Alex
With the old watchdog one was able to view the actual functions logs which was helpful for debugging.
I was thinking that write_debug
would print the stdout + stderr of the forked processed. Or is there already a method for getting those function debug logs?
print the stdout + stderr of the forked processed
Wanted to know the same thing. How can I print the stdout + stderr from the function process in the watchdog?
Hi @salminsu
write_debug writes out the function's input, that's what it was supposed to do.
To get the output from the function, just go ahead and log to STDOUT or STDERR.
Unless you're using the Python template with Flask, then you need to use the logger package.
Perhaps you can raise your own issue now since we have no context and please fill out the issue template too?
/lock
From my experimenting with the of-watchdog and looking at the code it seems the write_debug env variable is currently not used .
Expected Behaviour
Either write_debug is removed from the docs or it is implemented as specified by the README.MD
Current Behaviour
Possible Solution
Temporarily remove write_debug from the docs until it is implemented.
Steps to Reproduce (for bugs)
1. 2. 3. 4.
Context
Your Environment
Docker version
docker version
(e.g. Docker 17.0.05 ):Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Operating System and version (e.g. Linux, Windows, MacOS):
Link to your project or a code example to reproduce issue: