Open devinbost opened 2 hours ago
To address the issue of Alembic logging to a read-only location, you can modify the logging configuration to allow the log path to be set via an environment variable. This would enable you to redirect logs to a writable location without needing to modify the upstream repository.
Here's a potential approach to implement this:
Modify the Alembic Configuration: Update the Alembic configuration to use an environment variable for the log file path. You can do this by editing the alembic.ini
file to include a section that reads the log path from an environment variable.
Set the Environment Variable: In your deployment configuration (e.g., Kubernetes or OpenShift), set the environment variable to point to a writable directory. This could be a directory outside the read-only filesystem, such as a mounted volume.
Update the Code: If necessary, update the code where the Alembic logging is configured to check for the environment variable and use it to set the log file path.
This approach allows you to configure the log path dynamically based on your deployment environment, avoiding the need to write to a read-only filesystem. If you need further customization, you might consider reviewing the changes proposed in the GitHub pull request for additional ideas on handling logging in a read-only environment.
To continue talking to Dosu, mention @dosu.
When I bind-mount the entire alembic directory, I unsurprisingly get this error:
[10/22/24 12:07:46] ERROR 2024-10-22 12:07:46 - ERROR - service.py:196
service - Error initializing
alembic: Can't find Python file
/app/.venv/lib/python3.12/site-packa
ges/langflow/alembic/env.py
Bug Description
Alembic is logging to /app/.venv/lib/python3.12/site-packages/langflow/alembic/alembic.log
In a secure environment, the site-packages directory should be read-only.
When starting in such an environment, I get the following stack trace:
Reproduction
Deploy LangFlow into an OpenShift environment where the securityContext includes
readOnlyRootFilesystem: true
andrunAsNonRoot: true
. More complete example available here: https://github.com/langflow-ai/langflow-helm-charts/pull/15/filesExpected behavior
It should be possible to set this log path via an environment variable. If at least it was a directory instead of a file, I could use a bind-mount to override it, but when I bind-mount
/app/.venv/lib/python3.12/site-pa ckages/langflow/alembic/
, it breaks the library since other files are present in that directory. Not sure how to proceed. I'm hoping this is something we can fix in our implementation, rather than needing the upstream repo to change, since this is blocking deployment for a customer.Who can help?
No response
Operating System
OpenShift 4.14
Langflow Version
1.0.18
Python Version
3.10
Screenshot
No response
Flow File
No response