Skip to content

Commit

Permalink
[AIRFLOW-4445] mushroom cloud errors too verbose (#6952)
Browse files Browse the repository at this point in the history
* [AIRFLOW-4445] mushroom cloud errors too verbose

(cherry picked from commit 62f6070)
  • Loading branch information
tooptoop4 authored and potiuk committed Jan 21, 2020
1 parent cbdb65a commit 1c25a46
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
6 changes: 6 additions & 0 deletions airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ error_logfile = -
# access to configuration is controlled by role permissions.
expose_config = False

# Expose hostname in the web server
expose_hostname = True

# Expose stacktrace in the web server
expose_stacktrace = True

# Set to true to turn on authentication:
# https://airflow.apache.org/security.html#web-authentication
authenticate = False
Expand Down
9 changes: 7 additions & 2 deletions airflow/www/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,13 @@ def integrate_plugins():
@app.context_processor
def jinja_globals():
return {
'hostname': get_hostname(),
'navbar_color': conf.get('webserver', 'NAVBAR_COLOR'),
'hostname': get_hostname() if conf.getboolean(
'webserver',
'EXPOSE_HOSTNAME',
fallback=True) else 'redact',
'navbar_color': conf.get(
'webserver',
'NAVBAR_COLOR'),
}

@app.before_request
Expand Down
15 changes: 12 additions & 3 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,25 @@ def dag_details(self, session=None):
@current_app.errorhandler(404)
def circles(self):
return render_template(
'airflow/circles.html', hostname=get_hostname()), 404
'airflow/circles.html', hostname=get_hostname() if conf.getboolean(
'webserver',
'EXPOSE_HOSTNAME',
fallback=True) else 'redact'), 404

@current_app.errorhandler(500)
def show_traceback(self):
from airflow.utils import asciiart as ascii_
return render_template(
'airflow/traceback.html',
hostname=get_hostname(),
hostname=get_hostname() if conf.getboolean(
'webserver',
'EXPOSE_HOSTNAME',
fallback=True) else 'redact',
nukular=ascii_.nukular,
info=traceback.format_exc()), 500
info=traceback.format_exc() if conf.getboolean(
'webserver',
'EXPOSE_STACKTRACE',
fallback=True) else 'Error! Please contact server admin'), 500

@expose('/noaccess')
def noaccess(self):
Expand Down
15 changes: 12 additions & 3 deletions airflow/www_rbac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,26 @@ def get_date_time_num_runs_dag_runs_form_data(request, session, dag):
@app.errorhandler(404)
def circles(error):
return render_template(
'airflow/circles.html', hostname=socket.getfqdn()), 404
'airflow/circles.html', hostname=socket.getfqdn() if conf.getboolean(
'webserver',
'EXPOSE_HOSTNAME',
fallback=True) else 'redact'), 404


@app.errorhandler(500)
def show_traceback(error):
from airflow.utils import asciiart as ascii_
return render_template(
'airflow/traceback.html',
hostname=socket.getfqdn(),
hostname=socket.getfqdn() if conf.getboolean(
'webserver',
'EXPOSE_HOSTNAME',
fallback=True) else 'redact',
nukular=ascii_.nukular,
info=traceback.format_exc()), 500
info=traceback.format_exc() if conf.getboolean(
'webserver',
'EXPOSE_STACKTRACE',
fallback=True) else 'Error! Please contact server admin'), 500


class AirflowBaseView(BaseView):
Expand Down

0 comments on commit 1c25a46

Please sign in to comment.