Skip to content

Commit

Permalink
[AIRFLOW-566] Add timeout while fetching logs
Browse files Browse the repository at this point in the history
Closes apache#1834 from msumit/AIRFLOW-566
  • Loading branch information
msumit authored and r39132 committed Nov 3, 2016
1 parent 26bab26 commit 0d3ed4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def run_command(command):
# privacy.
demo_mode = False
# The amount of time (in secs) webserver will wait for initial handshake
# while fetching logs from other worker machine
log_fetch_timeout_sec = 5
[email]
email_backend = airflow.utils.email.send_email_smtp
Expand Down Expand Up @@ -427,6 +431,7 @@ def run_command(command):
web_server_host = 0.0.0.0
web_server_port = 8080
dag_orientation = LR
log_fetch_timeout_sec = 5
[email]
email_backend = airflow.utils.email.send_email_smtp
Expand Down
9 changes: 8 additions & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
from airflow.utils import logging as log_utils
from airflow.www import utils as wwwutils
from airflow.www.forms import DateTimeForm, DateTimeWithNumRunsForm
from airflow.configuration import AirflowConfigException

QUERY_LIMIT = 100000
CHART_LIMIT = 200000
Expand Down Expand Up @@ -759,7 +760,13 @@ def log(self):
log += "*** Fetching here: {url}\n".format(**locals())
try:
import requests
response = requests.get(url)
timeout = None # No timeout
try:
timeout = conf.getint('webserver', 'log_fetch_timeout_sec')
except (AirflowConfigException, ValueError):
pass

response = requests.get(url, timeout=timeout)
response.raise_for_status()
log += '\n' + response.text
log_loaded = True
Expand Down

0 comments on commit 0d3ed4d

Please sign in to comment.