-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs dont show up if running in Kubernetes #1130
Comments
It's not clear if it is just crush logs or all logs. My initial guess was that it's k8s, but I think now that it's a problem of python configuration or logging. It's not clear how logs are output. |
Sure, dockerfile is:
The kubernetes deployment is very straight forward - just loads the image and exposes a service. It's really strange. Sometimes I get some logs out of the app but not others. I read that setting an env var |
Why do you need dump init? Just run bottle with uwsgi in the front and you should see all the logs. Here is a container I use with bottle and uwsgi |
As oz123 said, this is a Kubernetes problem. The Kubernetes console is buffering the output of your application. This buffer will release as soon as a operation flush is invoked or reach its size limit. In order to deal it, specify an environment variable PYTHONUNBUFFERED=1 for forcing stdout/stderr to be totallty unbuffered. Or wrap your sys.stdout and sys.stderr in another object like ps_mem.py. More info at: |
This is most likely a Python 3 problem and not of Kubernetes. The Python 3 is probably buffering https://stackoverflow.com/questions/29663459/python-app-does-not-print-anything-when-running-detached-in-docker The official docs are missing this topic. The only bit of info I could find is https://docs.python.org/3.8/using/cmdline.html?#cmdoption-u and it missing the description of the Python 3 when stdout is redirected. There is a change message.
But I have no idea what is the |
Filled the bug upstream https://bugs.python.org/issue41449 |
Without any code for the logging configuration or the application it is hard to say. I run multiple (>20) bottle based apps in k8s for a good while now and I don't have this problem. |
@oz123 can you show the Dockerfile for those apps? |
The docker file alone is useless, you need also the configuration of the WSGI server. I use uWSGI, see the option
|
I would remove this and see what happens. |
If I remove this the stdout is unbuffered. So text is immediately flushed to output. Having a buffered output, just makes the text flush later.
Since the OP uses python3.7 I assume that stderr and stdout aren't buffered. |
@oz123 that's strange. If |
Really strange. I see all the logs/output from bottle when running on a local docker container. Running the same image on Kubernetes and the bottle output is hidden. Other output from my python shows up fine.
Any ideas why this would happen?
The text was updated successfully, but these errors were encountered: