airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-1412) airflow task logs can be arbitrarily large (leading to webserver log page hanging)
Date Fri, 28 Sep 2018 20:32:00 GMT

    [ https://issues.apache.org/jira/browse/AIRFLOW-1412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16632527#comment-16632527
] 

ASF GitHub Bot commented on AIRFLOW-1412:
-----------------------------------------

ashb closed pull request #2442: [AIRFLOW-1412] Add config to truncate the task log file
URL: https://github.com/apache/incubator-airflow/pull/2442
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py
index f568d5dc8e..9447112de0 100755
--- a/airflow/bin/cli.py
+++ b/airflow/bin/cli.py
@@ -457,6 +457,20 @@ def run(args, dag=None):
     logging.root.handlers[0].flush()
     logging.root.handlers = []
 
+    # truncate log files
+    max_log_file_size = conf.get('core', 'MAX_LOG_FILE_SIZE_BYTES')
+    if (
+        max_log_file_size and
+        os.path.exists(filename) and
+        os.path.getsize(filename) > int(max_log_file_size)
+    ):
+        command = 'truncate -s %s %s' % (max_log_file_size, filename)
+        try:
+            subprocess.check_call(command, shell=True)
+        except subprocess.CalledProcessError as e:
+            # don't fail the process just because log file truncate fails
+            logging.error(e)
+
     # store logs remotely
     remote_base = conf.get('core', 'REMOTE_BASE_LOG_FOLDER')
 
diff --git a/airflow/config_templates/default_airflow.cfg b/airflow/config_templates/default_airflow.cfg
index ddd1ba816e..49a5c057e3 100644
--- a/airflow/config_templates/default_airflow.cfg
+++ b/airflow/config_templates/default_airflow.cfg
@@ -35,6 +35,9 @@ dags_folder = {AIRFLOW_HOME}/dags
 # This path must be absolute
 base_log_folder = {AIRFLOW_HOME}/logs
 
+# The max size of each task log file
+max_log_file_size_bytes =
+
 # Airflow can store logs remotely in AWS S3 or Google Cloud Storage. Users
 # must supply a remote location URL (starting with either 's3://...' or
 # 'gs://...') and an Airflow connection id that provides access to the storage


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> airflow task logs can be arbitrarily large (leading to webserver log page hanging)
> ----------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-1412
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1412
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: webserver, worker
>            Reporter: Angela Zhang
>            Assignee: Angela Zhang
>            Priority: Minor
>             Fix For: 1.10.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message