phani8996 commented on a change in pull request #3992: [AIRFLOW-620] Feature to 
tail custom number of logs instead of rendering whole log
URL: https://github.com/apache/incubator-airflow/pull/3992#discussion_r223732458
 
 

 ##########
 File path: airflow/www/views.py
 ##########
 @@ -836,6 +839,21 @@ def log(self, session=None):
         dttm = pendulum.parse(execution_date)
         form = DateTimeForm(data={'execution_date': dttm})
         dag = dagbag.get_dag(dag_id)
+        metadata = {}
+        tailing_required = False
+        tail_lines_list = [100, 200, 500, 1000]
+        num_lines = 100
+        if conf.has_option('webserver', 'tail_lines_list'):
+            tail_lines_list = conf.get('webserver', 'tail_lines_list')
+            tail_lines_list = list(map(int, tail_lines_list.split(',')))
+        if conf.has_option('webserver', 'tail_logs'):
+            tailing_required = conf.getboolean('webserver', 'tail_logs')
+            if tailing_required and conf.has_option('webserver', 'num_lines'):
+                num_lines = conf.getint('webserver', 'num_lines')
+            metadata["num_lines"] = num_lines
+        if num_lines in tail_lines_list:
+            tail_lines_list.remove(num_lines)
 
 Review comment:
   That's to avoid duplicates. lets say user have added in config that dropdown 
should contain entries 100,200,500,1000 and user picked 100 as default number 
of lines to tail when user lands on get_logs page. Without this condition 
airflow ending showing 2 entries for 100 in dropdown. This will ensure no 
duplicates in such case

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to