Change stdout and stderr log access modes #25182
Unanswered
THISisZOLI
asked this question in
General
Replies: 1 comment 5 replies
-
Why don't you provide a PR fixing it ? I think the solution with "append" mode and truncation sounds lke a good idea. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Starting Airflow components using the
--stdout
and--stderr
arguments redirects the output streams to a log file. Currently the access type for these log files isw+
, as you can see below (might not include all affected components).Scheduler:
airflow/airflow/cli/commands/scheduler_command.py
Line 68 in de6938e
Flower:
airflow/airflow/cli/commands/celery_command.py
Line 70 in de6938e
Celery:
airflow/airflow/cli/commands/celery_command.py
Line 180 in de6938e
Webserver:
airflow/airflow/cli/commands/webserver_command.py
Line 452 in de6938e
Triggerer:
airflow/airflow/cli/commands/triggerer_command.py
Line 42 in de6938e
My problem with this access mode is that it can create sparse files. If the log file is moved or deleted, a new one will be created and the stdout/stderr will be written into it, but not from the start of the file. Instead if the original log file was
x
characters long, the new log file will containx
null bytes, and the new lines will be appended after that.This behaviour prevents us from rotating the log files properly. The only solution for it currently without changing the code is restarting the components after each log rotation, which is not really feasible.
I propose changing the access mode for these output files from
w+
toa
. As I've seen it from my tests it still creates the log file if it doesn't exist, but it does not print null bytes at the beginning of new files if the old one is deleted.The problem with this solution is that old output files are not automatically deleted (or, to put it better, overridden) at component start, which might result in very big output files in the long run. To preserve this behaviour, we could do something like this after opening the file:
Beta Was this translation helpful? Give feedback.
All reactions