A way to stream stdout?
Closed this issue · 3 comments
We would like to stream the output of the oc
command as it completes work. So far, we haven't been able to find a way; we can only get the full log once the command completes. Is there something simple I'm missing? Thanks! If there is a way, could you add an example file and/or doc showing how?
@jkugler I don't believe you are missing anything. This library is a wrapper written around the oc
command and the majority of it was written to provide a rich interaction with OpenShift via the oc
command. Because we support both local and remote executions, it's much easier for us to capture everything into our Result
class, and then pass that back to the consumer to deal with it, as they see fit.
Everything that you are looking for should be available inside of the Result
object returned from whatever Action
that you are performing. While the output may not be streaming real-time, it is available immediately after the action completes and can be written to the screen in multiple ways (action.out
, action.as_dict()
, action.as_json()
). Another nice feature of the action.as_*()
methods is the ability to redact sensitive information from the output.
Hopefully this helps! If you have any questions, please let us know.
Thanks for the answer! I'm trying to move our team to use the Python API, whether it be this API or https://github.com/openshift/openshift-restclient-python instead of directly shelling out to the oc
command, in order to better handle errors, etc. But, there is a lot of pushback because we then won't have streaming output for the developers so they can watch the progress, abort if there is a hang, etc.
I saw the restclient version had a watch
method on objects, so maybe that will return logs in real time. I need to investigate that.
No problem, happy to help!
We do provide error tracking as well as a timeout, on oc actions, that sound like it could be something that you could utilize versus the streaming logging. The following link is to a pretty simple example of both of these features:
openshift-client-python/examples/exception_tracking.py
Lines 37 to 47 in 3943e69